Wednesday, October 27, 2010

Flowcharts


The first flowchart determines whether the temperature is above or below the freezing point.   


This flowchart displays the one second response to a switch. It illustrates that the LED light would be on for one second before turning off.
The rectangles indicate the 'Process' steps.
The diamonds indicate the 'Decisions', or branches in the process.
The circles indicate 'Connectors' which act as jump nodes from one part of the process to another.
The ovals ( Terminators) indicate the process boundaries, showing where the process starts and stops.
The arrows ( Flow Lines) indicate the process flow direction.

Below is a flowchart which I attempted to make regarding the algorithm of traffic lights. It wasn't totally successful as I was trying to do it differently. Some of the lines overlapped but here is the final copy.

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