Tracing and predicting

About this lesson: Tracing and predicting

In short

To trace an algorithm, you follow it line by line and record every change in a trace table. This loop adds up the numbers from 1 to n. Step through and watch the table grow.

Tracing and predicting

What you'll explore

Trace tables: Follow it line by line
To trace an algorithm, you follow it line by line and record every change in a trace table. This loop adds up the numbers from 1 to n.
Predict first: What will it output?
Programmers predict the output before running a program. This one starts with 3 and doubles it three times.
Different inputs: Change the input, trace again
One input tests one case. Try a small start value, then a bigger one. Predict each output in your head first, then run it and check the trace table.
Check yourself: Trace it
The program is: INPUT a, then b ← a − 2, then a ← b × 2, then OUTPUT a. The input is 5.

Also in this lesson

  • Common mix-ups
  • A full trace
  • Paper computer

Words to know

trace
Follow an algorithm line by line, by hand.
trace table
A table showing each value the variables take.
predict
Work out what will happen before it happens.
loop
Steps that repeat, such as FOR … NEXT or REPEAT.
bug
A mistake in an algorithm or program.

Sources

  • BBC Bitesize GCSE Computer Science: Trace tables

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.

← Writing algorithms · Decisions in algorithms →

All lessons in Term 1 · Computing · Age 12