Selection and Repetition
As we have mentioned in previous lessons Algorithms are composed of three basic structures. Sequence, Selection and Repetition.
We have already looked at sequence (the single steps in the algorithms we did before are sequence) so what are selection and 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;
(you may need to research algorithms in google.
Use the word “if” ie If red then ……)
1. Moving through a set of traffic lights.
2. Deciding whether to take an umbrella to school.
3. Giving a student an A, B or C on their test.
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;
1. Adding the correct amount of cordial to water to make a drink.
2. Filling a bucket with water.
3. Blowing up a balloon.