GoalWork out how many times steps are repeated from an algorithm.
New words
trace · to follow an algorithm one step at a timetotal · all of something added togetherstep · one instruction in an algorithm
Explanation
Read a repeat step carefully. “Repeat steps 3 and 4 three more times” means the steps have been done once already, and then three more times. So they are done 1 + 3 = 4 times in all. To avoid mix-ups, a good algorithm can say the total: “Do steps 3 and 4 four times in all.” To find how many times an action happens, count the iterations, then multiply by the number of times the action appears in one iteration. A table helps you keep count. To trace an algorithm means to follow it one step at a time and write down what happens.
Step
Instruction
1
Start
2
Dig a hole
3
Drop in one seed
4
Cover the seed
5
Repeat steps 2 to 4 five more times
6
Stop
Worked examples
Time round
Seeds planted so far
1
1
2
2
3
3
4
4
5
5
6
6
Trace the seed algorithm in the picture above. Steps 2 to 4 are done once, then five more times, so six times in all. Six seeds are planted.
Sentence
Times in all
Repeat steps 2 and 3 four more times
1 + 4 = 5
Do steps 2 and 3 four times in all
4
These two sentences are not the same. “More” means extra times after the first time.
Fruit
In one iteration
In 5 iterations
apple
2
10
pear
1
5
When an iteration has more than one of an action, multiply. Each iteration puts 2 apples and 1 pear in a box. Five iterations give 5 × 2 = 10 apples and 5 × 1 = 5 pears.
Class activity
Pebble tracing (with family): follow this algorithm. 1 Put a pebble in a bowl. 2 Clap twice. 3 Repeat steps 1 and 2 five more times. Count the pebbles in the bowl and the claps you made. Write down your guess before you start. Then make your own algorithm with “more times” and let a partner guess the totals before doing it.
Practice
1
How many hops and how many spins does this algorithm make?
Step
Instruction
1
Start
2
Hop on one foot
3
Spin once
4
Repeat steps 2 and 3 two more times
5
Stop
3 hops and 3 spins.
2
“Repeat steps 2 to 4 six more times.” How many times are steps 2 to 4 done in all?
7 times (1 + 6).
3
Each iteration has 3 jumps and 1 clap. There are 5 iterations. How many jumps and claps in all?
15 jumps (3 × 5) and 5 claps.
4
How many plants are watered and how many steps are walked in this algorithm?
Step
Instruction
1
Start
2
Water one plant
3
Walk 2 steps
4
Repeat steps 2 and 3 four more times
5
Stop
5 plants are watered and 10 steps are walked (5 times 2).