← Years 5–6 Creating Digital Solutions

Finding and fixing a mistake in an algorithm

A mistake in an algorithm. Follow the steps until the result goes wrong, then fix that step. It might be in the wrong order, missing, or unclear.

Understanding Finding and fixing a mistake in an algorithm in Years 5–6 Creating Digital Solutions

What it does: The fixed algorithm now has the missing step 'Add butter' put in, so the sandwich turns out right. 'Walk a bit' is unclear because no one knows how far. Walking '10 steps forward' is exact, so it can be followed the same way every time. A bug is a mistake in an algorithm. It stops the algorithm from giving the right result. Following each step in order shows you where the result first goes wrong. That step is where the bug is. All the steps are there, but 'Eat the toast' comes too early. Moving it to the end fixes the bug.

Common mistakes: The steps are in the wrong order. You cannot eat the toast before it has been made. Step 2 should be 'Put bread in the toaster'. The steps are in the wrong order. Laces cannot be tied before the shoes are on. Step 1 should be 'Put on your socks'.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 21–30) and word search (Modules 21–40).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
What is a bug in an algorithm?
A mistake in the stepsA small insect on the computer
Matches
1. Pour milk on cereal 2. Get a bowl 3. Eat the cereal
↓
Wrong order: the milk is poured before there is a bowl. Move 'Get a bowl' to step 1.
Applying
Meanings
Term
bug
Meaning
A mistake in an algorithm. Follow the steps until the result goes wrong, then fix that step. It might be in the wrong order, missing, or unclear.
Practice
1. Get a slice of bread
Testing
Gaps
A mistake in an algorithm is called a
Check Answer
Spots
11. Get a slice of bread
22. Eat the toast

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Sperm Whale' badge — Deep Sea Champion, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. What is a bug in an algorithm?
A. A small insect on the computer
B. A mistake in the steps ✓
A bug is a mistake in an algorithm. It stops the algorithm from giving the right result.
2. How do you find a bug in an algorithm?
A. Follow the steps one by one until the result goes wrong ✓
B. Guess which step is wrong without following them
Following each step in order shows you where the result first goes wrong. That step is where the bug is.
3. Making toast: 1. Eat the toast. 2. Put bread in the toaster. 3. Wait for it to pop up. What type of bug is this?
A. Wrong order ✓
B. Missing step
All the steps are there, but 'Eat the toast' comes too early. Moving it to the end fixes the bug.
4. Brushing teeth: 1. Wet the toothbrush. 2. Brush your teeth. 3. Rinse your mouth. The toothpaste never gets used. What type of bug is this?
A. Wrong order
B. Missing step ✓
There is no step for putting toothpaste on the brush. Adding that step after step 1 fixes the bug.
5. An algorithm says: 'Draw a line.' The robot does not know how long or in which direction. What type of bug is this?
A. Unclear step ✓
B. Wrong order
The step does not give enough detail. A clear step would be 'Draw a straight line 5 cm long going across.'

Match the Pairs

bug → A mistake in an algorithm that makes the result go wrong
1. Put on shoes 2. Put on socks → A bug: the steps are in the wrong order
To fix a missing step bug, add the step that was left out → 1. Get bread 2. Add butter 3. Add cheese 4. Close sandwich
To fix an unclear step bug, make the step exact so anyone can follow it → Walk 10 steps forward
1. Pour milk on cereal 2. Get a bowl 3. Eat the cereal → Wrong order: the milk is poured before there is a bowl. Move 'Get a bowl' to step 1.
1. Wet your hands 2. Rinse your hands 3. Dry your hands → Missing step: there is no step to wash with soap. Add 'Rub soap on your hands' after step 1.

Key Term

bug
A mistake in an algorithm. Follow the steps until the result goes wrong, then fix that step. It might be in the wrong order, missing, or unclear.

Fill in the Blanks

1. A mistake in an algorithm is called a bug
Hint: Type the word for a mistake in an algorithm
2. 1. Put on shoes 2. Put on socks Bug: step 1 should come after step 2
Hint: Type the step number that is in the wrong order
3. Bug: the step "Switch on kettle" is missing
Hint: Type the word that describes a step that was left out
4. 2. Add some sugar Bug: "some" is vague, so it is unclear
Hint: Type the word for a step that is not clear enough to follow
5. Follow the steps until the result goes wrong Then fix that step
Hint: Type the action you take on the step that causes the problem

Spot the Error

Question 1
A 1. Get a slice of bread
B 2. Eat the toast
C 3. Push the lever down
D 4. Wait for the toast to pop
Line B — The steps are in the wrong order. You cannot eat the toast before it has been made. Step 2 should be 'Put bread in the toaster'.
Question 2
A 1. Tie your laces
B 2. Put on your shoes
C 3. Tie your laces
Line A — The steps are in the wrong order. Laces cannot be tied before the shoes are on. Step 1 should be 'Put on your socks'.
Question 3
A 1. Get a cup
B 2. Put a teabag in the cup
C 3. Pour in hot water
D 4. Wait for a while
Line D — This step is unclear. 'A while' does not say how long to wait, so different people would get different results. It should say 'Wait for three minutes'.
Question 4
A 1. Fill the watering can
B 2. Carry it to the plant
C 3. Put the can away
Line C — A step is missing. The plant never gets watered because the 'Tip water onto the soil' step was left out. Step 3 should be 'Tip water onto the soil'.
Question 5
A SET total TO 0
B REPEAT 3 TIMES
C ADD some TO total
D SHOW total
Line C — This step is unclear. 'some' is not a number, so the computer cannot add it. It should say 'ADD 2 TO total'.

Student with a class code? Join your class →