Monday, July 30, 2012

Selection and Repitition

Algorithms are composed of three basic structures:
  • Sequence
  • Selection
  • Repetition
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.

DESCRIBE IN PLAIN ENGLISH, AN ALGORITHM FOR:

Question 1: Moving through a set of traffic lights
When approaching a set of traffic lights, determine what colour it is. If it is green, then proceed through, if orange then slow down and prepare to come to a stop, if red, then come to a complete stop behind the line or behind the car in front of you

Question 2: Deciding whether to take an umbrella to schoolCheck the weather outside and also on the news. If it is windy and cloudy, take the umbrella, if it is a clear sunny day then don't.

Question 3: Giving a student an A, B or C on their test
Check what mark the student got on their exam test. If the mark is average, then give the student a C, if the student has a high mark then give them a B, and if the student has an excellent mark, then give them an A.

Often an algorithm will often require you to repeat a task in order to solve a problem; when this is done in an algorithm, the structure is called repetition.

DESCRIBE IN PLAIN ENGLISH, AN ALGORITHM FOR:

Question 1: Adding the correct amount of cordial to water to make a drink
Get a medium sized glass for a person and using the ratio, Water: 3/4 and Cordial: 1.4 and make the cordial. Do this for as many people as there are.

Question 2: Filling a bucket with water
Get a bucket and put right under the tap. Turn tap so that the water starts flowing smoothly, not very fast. Wait for a minute and check if the bucket is filled with water yet. When the water is about 3 centimetres away from the brim of the bucket, turn the tap and close it. Now carry the bucket and use the water whenever you need to

Question 3: Blowing up a balloon
Get a balloon. With your mouth, start blowing up the balloon until you reach a desired size, usually medium, not too big, not too small. When you feel that you have reached that size, stop blowing the balloon and take away from your mouth, keeping your hand on the nozzle of the balloon so that the air inside it doesn't escape. Now tie a knot on the balloon.

No comments:

Post a Comment