GoalSay what an algorithm is and write an everyday task as ordered steps.
New words
algorithm · a set of exact steps, in a logical order, that solves a probleminstruction · one clear step that can be carried outorder · the sequence in which steps are done; changing it can change the resultfinite · having an end; an algorithm must stop after some steps
Explanation
An algorithm is a list of steps in a logical order that solves a problem. You already follow algorithms: a recipe, the steps for packing a school bag, or the way you check whether a number is even. A good algorithm has three marks. Its steps are clear and exact, so that nobody has to guess. Its steps are in the right order, because changing the order can change the result. And it ends: after a limited number of steps the problem is solved. The clearer the steps, the easier the solution is to turn into code. An instruction such as “make it nice” is not clear enough; “write the title in the top line” is. Algorithms are not only for computers: a person can follow them too.
look at the timetable→take the books→put them in the bag→add a water bottle→close the bag
Worked examples
Step
What to do
1
find the remainder of the number ÷ 2
2
if it is 0, say “even”
3
otherwise say “odd”
Mona’s algorithm for deciding whether a number is even has three steps: find the remainder after dividing by 2; if the remainder is 0, say even; otherwise say odd. Remember Week 2: the same steps became the if and else program.
close the bag→take the books→books stay out
Omar wrote the school-bag steps but put “close the bag” before “take the books”. The steps are all correct, but the order is wrong, so the books stay on the desk. The order of the steps is part of the algorithm.
Class activity
Write an algorithm of five steps for watering a plant. Swap two of the steps and say what goes wrong. Then check that each step is clear enough that a younger child could do it.
Practice
1
What is an algorithm?
Exact steps in a logical order that solve a problem.
2
Why does the order of steps matter?
Changing the order can change the result or make the solution fail.
3
Is “do the work somehow” a good instruction for an algorithm?
No. It is not clear or exact, so a person would have to guess.
4
Name one algorithm from daily life that is not a computer program.
For example a recipe, or the steps for packing a school bag.