Reading and repairing pseudocode

About this lesson: Reading and repairing pseudocode

In short

This algorithm should output the larger of two numbers. Choose values for a and b and run it line by line. Try several pairs: does it always give the larger one?

Reading and repairing pseudocode

What you'll explore

Trace it: Does it always work?
This algorithm should output the larger of two numbers. Choose values for a and b and run it line by line.
Find the bug: The first wrong step
Trace with a = 3 and b = 8. At each line, compare what happens with what should happen. The first step that gives a wrong result is where the bug is.
Repair and retest: Run the same case again
Swap the two outputs and trace again with the same values. Then test other pairs, including a = b. A repair isn't finished until you have tested it.
Check yourself: Spot the step
An algorithm should output 'Pass' when mark ≥ 50. It says: IF mark > 50 THEN OUTPUT "Pass".

Also in this lesson

  • Common mix-ups
  • Two versions
  • Instruction bugs

Words to know

algorithm
A set of steps to solve a problem.
pseudocode
A structured, readable way to write an algorithm.
trace
Follow an algorithm step by step, recording values.
bug
An error in an algorithm or program.
debug
Find and fix bugs.

Sources

  • BBC Bitesize KS3 Computer Science
  • Raspberry Pi Foundation, Computing curriculum resources

An interactive lesson with a live experiment: move the sliders, press the buttons and answer quick questions. 4 short steps and a 6-question quiz. Part of the Family plan. Written and checked by Shalo Lab. Last updated 11 November 2026.

Following a loop →

All lessons in Term 1 · Computing · Age 13