Wednesday, July 21, 2010

Selection and Repition

Solving a problem often involves making a decision between two or more options. In an algorithm this process of making a decision is called selection. Repition is important to get the desired effect or objective.

Here are some examples of an algorithm:
Moving through a set of traffic lights
1) start driving until a set of traffic lights are in sight
2) if the lights are green keep going at the same speed
3) if the lights are orange slow the speed of the car down
3) if the lights are red stop the car at the line or behind the car in front

Blowing up a balloon.
1) strech balloon a bit
2) inhale deeply and hold
3) raise balloon to lips
3) blow into the balloon
4) pinch the neck of the balloon
5) look to see if balloon is at a satisfactory size
6) if too small repeat steps 2-6
7) if too big open neck a little bit for 2 seconds

No comments:

Post a Comment