Monday, July 25, 2011

Selection and Repetition


ALGORITHMS
• Moving through a set of traffic lights.
1. If the traffic light is red then stop and wait until the light turns green.
2. If the traffic light is green then keep going do not stop.
3. If the traffic light is yellow then prepare to stop, if you can go through yellow before it goes red then keep going.
• Deciding whether to take an umbrella to school.
1. If it is raining then take an umbrella to school
2. If the weather seems cloudy and is about to rain then take an umbrella to school.
3. If the sun is shining and no chances of rain then do not take an umbrella to school.

• Giving a student an A, B or C on their test.
1. If the student has met the criteria is meant for an A then give an A.
2. If the student has met the criteria is meant for a B then give a B.
3. If the student has met the criteria is meant for a C then give a B.

Describe, in plain English, an algorithm for;
• Filling a bucket with water.
1. Get a bucket any colour and size.
2. Go to a tap.
3. Place the bucket underneath the tap.
4. Let the bucket fill with water.
5. Remove it from underneath the tap and close the tap.

• Blowing up a balloon.
1. Take a balloon of any colour.
2. Either blow it up with your mouth.

OR
1. Take a balloon of any colour.
2. Take an air pump.
3. Put the face of the balloon on the pump and put pressure in it to blow it up.



No comments:

Post a Comment