Efficient algorithms
Answers are for parents and teachers.
1
Write an algorithm for walking from your door to the table, one step at a time. Then write a shorter one by joining steps. How many steps did you save?
Check that the steps are in order, that the same side-by-side steps are joined, and that the child counts the steps correctly.
2
Rewrite with fewer steps: Start, Move 1, Move 1, Turn left, Move 1, Move 1, Move 1, Stop.
Start, Move 2, Turn left, Move 3, Stop. That is 5 steps instead of 8.
3
Think about setting the table for four people. Which steps repeat? Write the algorithm using “repeat”.
For example: Repeat 4 times: put down a plate, put a spoon next to it, put down a cup. These steps happen once for every person.
4
Do the steps cancel out? Turn left, Turn right, Move 3.
Yes. They cancel out, so the algorithm becomes just “Move 3”.
5
Tell a grown-up two reasons why efficient algorithms are good.
They are quicker to write and easier to check. Efficient programs also help computers use less power.