Escolar Documentos
Profissional Documentos
Cultura Documentos
Ramesh Sankaranarayana
Research School of Computer Science Australian National University Canberra, ACT
Algorithms
1 / 14
Outline Introduction
Algorithms
2 / 14
Outline Introduction
Problem Statement
Spacecraft Launch A reusable spacecraft, Space Ship One, is to be launched from a mother ship at an altitude of 25, 000 feet. Assuming that the spacecraft uses all its fuel to achieve a vertical velocity u at launch, what is the value of u for the spacecraft to reach outer space (an altitude of 100 km)?
Algorithms
3 / 14
Outline Introduction
Algorithms
Denition Informally, an algorithm is a step-by-step procedure to solve a problem. A recipe, as it were. There is no commonly accepted formal denition of an algorithm. We will use the following one by Stone (1972): We dene an algorithm to be a set of rules that precisely denes a sequence of operations such that each rule is eective and denite and such that the sequence terminates in a nite time.
Algorithms
4 / 14
Outline Introduction
Algorithms
Denition He explains that: For people to follow the rules of an algorithm, the rules must be formulated so that they can be followed in a robot-like manner, that is, without the need for thought... however, if the instructions are to be obeyed by someone who knows how to perform arithmetic operations but does not know how to extract a square root, then we must also provide a set of rules for extracting a square root in order to satisfy the denition of algorithm.
Algorithms
5 / 14
Outline Introduction
Algorithms
Denition and Not all instructions are acceptable, because they may require the robot to have abilities beyond those that we consider reasonable. as well An intuitive denition of an acceptable sequence of instructions is one in which each instruction is precisely dened so that the robot is guaranteed to be able to obey it.
Algorithms
6 / 14
Outline Introduction
Algorithms
Examples Print the rst 100 positive integers. The long division algorithm. Maintaining an aircrafts altitude in ight.
Algorithms
7 / 14
Outline Introduction
Algorithms
Algorithms
8 / 14
Outline Introduction
Problem Statement
Spacecraft Launch A reusable spacecraft, Space Ship One, is to be launched from a mother ship at an altitude of 25, 000 feet. Assuming that the spacecraft uses all its fuel to achieve a vertical velocity u at launch, what is the value of u for the spacecraft to reach outer space (an altitude of 100 km)?
Algorithms
9 / 14
Outline Introduction
Algorithms
Pseudocode cmsPerInch = 2.54 % from conversion inchesPerFt = 12 % from conversion metersPerCm = 1/100 % from conversion metersPerFt = metersPerCm * cmsPerInch inchesPerFt g = 9.81 % m/sec^2 finalAltitude = 100 % km. Given initialAltitude = 25000 % ft. Given. tables tables tables *
Algorithms
10 / 14
Outline Introduction
Architecture
memory
control unit
ALU AC
input/output
Algorithms
11 / 14
Outline Introduction
Architecture
Main components Central Processing Unit (CPU) Memory - main (RAM) and secondary (hard drives, ash cards, etc.) Bus - Data, Address and Control Program Counter (PC) Arithmetic and Logic Unit (ALU) Registers - instruction, status, index, accumulator Input/Output (I/O) Devices
Algorithms
12 / 14
Outline Introduction
Programming Languages
Generations First generation - machine language. Processor dependent. Hard to program. Not portable. Second generation - assembly language. More like a symbolic version of machine language. Easier to program, but still tedious. Examples - 8086 and PDP-11 assembly languages. Third generation - more similar to spoken language. Much easier to program. Much more portable. Examples - C, Fortran. Fourth generation - completely portable between supported processor types. Each line of code produces signicant amount of machine instructions. Examples - Java, Ada, C#, Matlab, SQL. Includes Domain Specic Languages like OCL, QVT, Eclipse Modeling Framework, grep, sed.
ENGN2219 Computing for Engineering Simulation Algorithms 13 / 14
Outline Introduction
Programming Languages
Programming Paradigms Imperative - Also called procedural. Traditional approach. A sequence of commands that leads to the desired output. Examples - C, FORTRAN, COBOL and Ada. Declarative - Develop a precise statement of the problem, rather than an algorithm for solving the problem. Built on an underlying general problem-solving algorithm. Formal logic provides such an algorithm. Example - Prolog. Functional - Programs written as a bunch of functions. Recursion and nesting is natural in this approach. Example Haskell. Object Oriented - The system is specied as a collection of objects and interactions between these objects. Examples Simula, Smalltalk, Java, C++, C#.
ENGN2219 Computing for Engineering Simulation Algorithms 14 / 14