1
Follow every step
Computing 3: Unit 1, pp. 8–27
GoalFollow an algorithm one step at a time to find out where it leads.
New words
algorithm · a list of steps, in the right order, that solves a problemstep · one instruction in an algorithmfollow · to do the steps exactly, one at a time, in order
Explanation
An algorithm is a list of steps. The steps must be in the right order. To check an algorithm, follow it one step at a time, just as a computer does. Do not skip a step and do not guess. Put a finger on the start square, do step 1, then step 2, and so on. When the last step is done, look at where you are. Only then can you say whether the algorithm works.
Worked examples
A girl starts at the bottom-left square. Her algorithm is: 1 Move 2 squares right. 2 Move 3 squares up. 3 Move 1 square right. After step 1 she is two squares along the bottom. After step 2 she is at the top. After step 3 she reaches the school.
A computer does exactly what each step says. If a step says “Move 2 squares”, it moves exactly 2 squares, not 1 and not 3. That is why we must read every number and every direction with care.
Another algorithm: 1 Move 4 squares right. 2 Move 2 squares up. Starting at the bottom-left, the robot goes along the bottom row and then up two squares. It stops at the house.
Class activity
Human robot (with a friend): draw a grid of squares on the floor with chalk or strips of paper, 5 squares wide and 4 tall, or draw it on squared paper and use a coin. Your friend writes an algorithm of three or four steps, such as “Move 2 squares right, Move 1 square up”. Follow it one step at a time and stand on, or place the coin on, the end square. Your friend checks. Then swap jobs.
Practice
1
Follow this algorithm from the start square. Where does the robot finish: the flower, the tent or the shop? 1 Move 3 squares right. 2 Move 2 squares up. 3 Move 1 square left.
The flower. It goes 3 right, 2 up, then 1 left.
2
A child follows this algorithm: 1 Put on socks. 2 Put on shoes. A friend does step 2 first. What goes wrong?
The shoes would be on first, so the socks cannot go on over them. The order of steps matters.
3
Write an algorithm that takes the robot from the start square to the star. Use steps like “Move 2 squares right”.
For example: 1 Move 3 squares right. 2 Move 2 squares up. (Moving up first and then right also works.)
4
The robot starts in the bottom-left square and follows this algorithm. How many squares does it move in all? In which row does it stop?
| Step | Instruction |
|---|---|
| 1 | Start |
| 2 | Move 2 squares right |
| 3 | Move 1 square up |
| 4 | Stop |
3 squares: 2 to the right and 1 up. It stops in the second row from the bottom, in the third column.