Learning Objectives
- Explain the purpose of a dry-run.
- Construct and complete a trace table.
- Record variable changes, conditions and outputs accurately.
- Use a trace to reveal logic errors.
Key Terms
- Trace table
- A table recording selected variable values and outputs as an algorithm is followed manually.
- Dry-run
- Manual execution of an algorithm using chosen input data.
- Iteration
- One repetition of a loop.
- Column
- A vertical part of the trace table assigned to a variable, condition or output.
- Blank entry
- A cell left empty when a value has not changed or an output has not occurred, according to the tables convention.
- Logic error
- An error that allows an algorithm to run but produces an incorrect result.

Purpose Of A Trace Table
A trace table documents a dry-run. It shows how data changes as each relevant statement executes. This helps a student determine an output, understand an unfamiliar algorithm or locate a logic error.
The columns depend on the algorithm and the question. They may include input values, counters, totals, loop variables, conditions, flags and outputs.
Preparing The Table
Read the algorithm first and identify variables that change. Use the columns supplied by the question when provided. If constructing a table, include only values needed to show the algorithm clearly.
Record initial values before the first iteration where appropriate. Then follow the algorithm in execution order. Do not jump directly to the result, because intermediate values are often where errors become visible.
Recording Changes
A new row may be used for each significant event, each iteration or each output, depending on the question format. Enter a value only when required by the convention. Some mark schemes expect unchanged cells to remain blank, while others repeat values; follow the layout provided.
Conditions can be recorded as TRUE/FALSE. An output column should contain a value only when an OUTPUT statement runs. Input values should appear when the INPUT statement is reached.
Example Trace
| Iteration | Value | Total | Count | Output |
|---|---|---|---|---|
| Initial | 0 | 0 | ||
| 1 | 4 | 4 | 1 | |
| 2 | 7 | 11 | 2 | |
| 3 | 2 | 13 | 3 | |
| After loop | 13 | 3 | 13 |
Finding Errors With A Trace
If a total unexpectedly resets, the table may show that initialisation is inside the loop. If a loop runs one time too many, the loop variable or condition column reveals the extra iteration. If a maximum never changes, the comparison direction or starting value may be wrong.
A trace identifies where behaviour first differs from the expected process. The correction should target the cause, not merely change the final output.
Accuracy Method
- Use the exact input order.
- Follow assignments from right to left: evaluate then store.
- Record the result of each decision before choosing a branch.
- Update loop variables at the correct point.
- Stop as soon as the loop condition fails or the algorithm ends.
- Record output only when an output statement executes.
Worked Examples
Counter Trace
Question: Trace Count for values 8, 3, 10 when Count increases for Value > 5.
- Initial Count = 0.
- 8 > 5, so Count = 1.
- 3 > 5 is false, so Count remains 1.
- 10 > 5, so Count = 2.
Answer: The final count is 2.
Detecting A Reset
Question: A supposed total has values 5, then 7, then 2 after inputs 5, 7, 2. What likely error exists?
- A running total should be 5, 12, 14.
- The observed value equals each latest input.
- The accumulator is probably reset before each addition or assigned Value instead of Total + Value.
Answer: Move initialisation before the loop and update using Total ← Total + Value.
Examination Guidance
- Follow the table format and blank-cell convention supplied.
- Do not calculate mentally and fill only the final row.
- Record conditions and outputs at the exact time they occur.
- Use a pencil-and-paper dry-run to check amended algorithms.
- When identifying an error, refer to the first incorrect state shown by the trace.
Common Mistakes
- Updating several statements at once without respecting order.
- Repeating an output on every row when it occurs once.
- Ignoring initial values.
- Continuing after the loop condition becomes false.
- Changing input data during the trace.
Knowledge Check
1. What is a dry-run?
2. What does a trace table record?
3. Why include initial values?
4. When is an output recorded?
5. How can a trace reveal a logic error?