Thursday, July 21, 2011

Selection and Repetition

Describe, in plain english, an algorithm for;
(you may need to research algorithms in google.
Use the word “if” ie If red then ……)

1. Moving through a set of traffic lights.
When driving the car and going through a set of light you have three options :
If green light keep going. if yellow light start to slow down and if red light brake and stop

2. Deciding whether to take an umbrella to school.
If the forecast has said rainy and it has been raining on previous days then take umbrella becasue there's a high chance of wet weather if the weather is sunny and bright then don't take umbrella to school. If it is cloudy and sunny pack your umbrella in your bag.

3. Giving a student an A, B or C on their test.
Calculate the students marks and then compare to the criteria available then determine the students marks from there

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.
1. Adding the correct amount of cordial to water to make a drink.
Get jug of water and pour cordial into jug and repeat until its to your prefrence of taste

2. Filling a bucket with water.
Fill bucket upto rim if over flows tip some water out and refill to the rim making sure that the water doesnt over flow if so then repeat process

3. Blowing up a balloon.

No comments:

Post a Comment