Tuesday, October 19, 2010

Algorithms

COMPUTERS NEVER DO WHAT YOU WANT THEM TO DO...
THEY ONLY DO WHAT YOU TELL THEM TO!
Definitions
Algorithm - An algorithm is a precise step-by-step plan for a procedure with a finite number of steps.
Pseudocode - A pseudocode is an artificial and informal language that helps programmers to develop algorithms.
Machine Language - A programming language that is interpreted and executed directly by the computer.
High Level Computer Language - Programming language with strong abstraction from the details of the computer.
Flowchart - A diagram of the sequence of operations in a computer program or an accounting system.
Sequence - A serial arrangement in which things follow a logical order or a recurring pattern.
Selection - The act of choosing or selecting. ('If' or 'Then')
Repetition - The act or process of repeating a set or sequence of instructions.

Example - Opening a Door and Entering a Room
1. Position yourself in front of the door
2. Lift your hand slightly
3. Rest your hand on the door knob
4. Twist in a clockwise direction and pull
5. Release the door knob
6. Walk straight forward through the door
7. Enter the room

Example - Traffic Lights Algorithm
1. Approach lights
2. Check colour of light
3. If the light is green, then continue driving
4. If the light is red, then prepare to stop
5. If the light is orange, then slow down

Tips on algorithms...
- Words such as 'if' and 'then' are known as selection ('If'... 'then'...)
- Algorithms are meant to be in sequence (order) of how they are to happen
- Repetition is also frequently used to rely information

No comments:

Post a Comment