Trace Tables
Master Trace Tables for GCSE Computer Science with this free worksheet and full mark scheme — Foundation and Higher exam-style questions with worked answers for AQA GCSE Computer Science (8525). A trace table records the value of each variable as an algorithm runs, step by step.
Free downloads
These worksheets and mark schemes are original, written for Virtus Academy and checked against the current AQA specification. Every worksheet comes with a full mark scheme.
Topic overview
A trace table records the value of each variable after every step of an algorithm, showing exactly what the program does as it runs.
Each variable has a column, with an extra column for any output. Each row records one step. When a variable changes, write its new value in that row; leave the cell blank or repeat the value if it is unchanged.
Trace tables are used to find logic errors, because they reveal exactly where the values stop behaving as expected. Working through a loop one iteration at a time, rather than trying to predict the outcome, is what makes them reliable — and rushing the loop is where nearly all trace table marks are lost.
Revision notes
Setting up the table
One column per variable, plus a column for any output.
Each row records the state after one step of the algorithm. Fill in the initial values first, before any statements execute.
Working through a loop
Complete one full iteration per row, in order, without skipping ahead.
Check the loop condition each time before deciding whether to continue. Trying to predict the outcome rather than tracing it is where nearly all marks are lost.
Finding errors
The table shows exactly where the values stop matching what was expected.
This pinpoints the statement causing a logic error. A logic error produces the wrong output without crashing, which is why tracing is needed to find it.
Key points
- A trace table records variable values step by step.
- Each variable has its own column.
- An extra column records output.
- Each row is one step of the algorithm.
- Complete one loop iteration per row.
- Trace tables find logic errors.
Worked examples
Example 1
An algorithm sets count ← 0 then adds 1 three times. State the value of count after each addition. [3 marks]
Working
Example 2
Explain why a trace table is useful for finding a logic error. [2 marks]
Working
Example 3
State what should be recorded in the output column of a trace table. [1 mark]
Working
Common mistakes
Skipping loop iterations.
Trace every iteration in order, one per row.
Predicting the result instead of tracing.
The whole point is to follow the algorithm mechanically.
Forgetting the output column.
Any displayed value must be recorded.
Not recording initial values.
Fill in the starting values before tracing any statements.
Exam tips
- Trace one step per row without skipping.
- Include a column for output.
- Record initial values before starting.
- Check the loop condition each iteration.
Key terms
- Trace table
- A table recording variable values at each step.
- Iteration
- One pass through a loop.
- Logic error
- An error producing wrong output without crashing.
- Dry run
- Working through an algorithm by hand.
Related topics
Written and reviewed against the current AQA specification. Spotted an error? Let us know.