2
Steps in the right order
Computing 2: Unit 1, pp. 8–23
GoalPut the steps of an algorithm in the right order and say why the order matters.
New words
order · which step comes first, next and lastresult · what you get at the endswap · to change the places of two things
Explanation
The steps of an algorithm must be in the right order. If the order is wrong, the result is wrong. Think about getting ready to go out. You put on your socks first and then your shoes. If you put your shoes on first, the socks go on top of the shoes! A computer follows the steps one by one, from the first to the last. It never changes the order for you.
Worked examples
Planting a seed: first fill the pot with soil, next put in the seed, last add water. This is the right order.
| Step | Ali’s algorithm | Better algorithm |
|---|---|---|
| 1 | Eat the soup | Pour the soup into a bowl |
| 2 | Pour the soup into a bowl | Eat the soup |
Some steps can swap places and some cannot. You can put your hat on before or after your coat. But you cannot tie your shoelaces before the shoes are on your feet.
Class activity
Order cards: on five small pieces of paper write these steps for washing your hands: turn on the tap, wet your hands, rub soap on your hands, rinse the soap off, dry your hands. Mix up the cards. A friend puts them in the right order. Then swap two cards on purpose and read the algorithm out loud. What goes wrong?
Practice
1
Put these steps in the right order: A Eat the apple. B Wash the apple. C Pick up the apple.
C, B, A. Pick it up, wash it, then eat it.
2
Put the steps for making a cheese sandwich in the right order.
C, B, A. First get the bread, then add the cheese (and put the other slice on top), then eat it.
3
Why must a computer follow the steps in the right order?
It does exactly what the steps say, one by one. The wrong order gives a wrong result.
4
Malika writes: 1 Put the bread in the toaster. 2 Spread butter on the toast. 3 Push the lever down. Which two steps should swap?
| Step | Malika’s algorithm |
|---|---|
| 1 | Put the bread in the toaster |
| 2 | Spread butter on the toast |
| 3 | Push the lever down |
Steps 2 and 3. The toast must be made before the butter goes on.