1 minute read

DRAFT

We only write the instructions inside an indefinite loop once. This makes the algorithm more concise. This means the algorithm is shorter and uses the fewest number of instructions possible. We do not have to write the same instructions over and over again. Also, when we need to change one of the instructions, we only need to do it once!

Edit and correct repeating algorithms

In algorithms, the instructions need to be as clear as possible to the person who has to follow those instructions.

When an algorithm is wrong, a programmer corrects the algorithm to make it work.

Sometimes, an algorithm isn’t wrong but a programmer thinks of a better way of doing something in the algorithm. When this happens, the programmer edits the algorithm to change it and make it better.

Imagine a person is learning a new dance. They want the instructions to be easy to follow. They also want the instructions to be as concise as possible, so they can learn the dance quickly.

Look at the instructions for a simple dance routine on the next page.

1 Step forward, starting with left leg for 2 steps.

2 Step backwards, starting with left leg for 2 steps.

3 Clap to the left.

4 Clap to the right.

5 Put your hands on your hips.

6 Jump forwards.

7 Jump backwards.

8 Jump a quarter turn right.

9 Step forward, starting with left leg for 2 steps.

10 Step backwards, starting with left leg for 2 steps.

11 Clap to the left.

12 Clap to the right.

13 Put your hands on your hips.

14 Jump forwards.

15 Jump backwards.

16 Jump a quarter turn right.

17 Step forward, starting with left leg for 2 steps.

18 Step backwards, starting with left leg for 2 steps.

19 Clap to the left.

20 Clap to the right.

21 Put your hands on your hips.

22 Jump forwards.

23 Jump backwards.

24 Jump a quarter turn right.

25 …

This is difficult to read. It is easy to get lost in the long list of instructions.

An algorithm with a repeating loop is much more concise and easier to follow.