☰ Year plan · Communication Technology

Algorithms and flowcharts

Week 4 · Unit 1, Lesson 2 Artificial Intelligence Algorithms (1) · 3 lessons
1

What is an algorithm? Ordered steps

ICT Prep 3 Term 1, Unit 1, Lesson 2: pp. 19–22
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.

Worked examples
StepWhat to do
1find the remainder of the number ÷ 2
2if it is 0, say “even”
3otherwise 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.
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?
2
Why does the order of steps matter?
3
Is “do the work somehow” a good instruction for an algorithm?
4
Name one algorithm from daily life that is not a computer program.