1. What is a Trace Table?
A Trace Table (also called a dry-run table) is a structured matrix used to track the values of variables as an algorithm program executes line by line. It is a visual way to perform a code trace and check your program's logic for errors.
In Cambridge IGCSE Computer Science (0478/0984) Paper 2 and A-Level (9618) Paper 2 & 4, trace tables account for up to 15–20% of your total exam mark. Examiners use trace tables to test whether you truly understand loop boundaries, logic conditions, and variable state updates at each algorithm step.
2. Official Cambridge Column Rules
When completing a trace table in exam conditions, follow these strict rules:
1. Scalar Variables Column
Every scalar variable declared or modified (e.g., Count, Total, Flag) receives its own dedicated column in order of declaration.
2. Array Index Columns
If an array is declared, every index must have its own separate column header: List[1], List[2], List[3]. Cambridge pseudocode arrays are 1-indexed!
3. The OUTPUT Column
The final rightmost column is ALWAYS labeled OUTPUT. Whenever the code executes OUTPUT ..., record the exact text or number printed.
3. Step-by-Step Trace Table Walkthrough
Consider the following pseudocode script that calculates the sum of even numbers from 1 to 4. We will perform a complete table walkthrough for this code:
DECLARE Sum : INTEGER
Sum ← 0
FOR Count ← 1 TO 4
IF Count MOD 2 = 0 THEN
Sum ← Sum + Count
ENDIF
NEXT Count
OUTPUT "Final Sum is: ", Sum
Here is the exact Cambridge Trace Table for this script:
| Count | Sum | OUTPUT |
|---|---|---|
| - | 0 | |
| 1 | ||
| 2 | 2 | |
| 3 | ||
| 4 | 6 | |
| - | - | Final Sum is: 6 |
4. Tracing 1D and 2D Arrays
When tracing an array algorithm (like a Bubble Sort or Linear Search), each element must be recorded in its respective column when modified.
Scores[1] ← 15
Scores[2] ← 25
Scores[3] ← Scores[1] + Scores[2]
OUTPUT Scores[3]
| Scores[1] | Scores[2] | Scores[3] | OUTPUT |
|---|---|---|---|
| 15 | |||
| 25 | |||
| 40 | |||
| 40 |
5. Common Exam Pitfalls & Mistakes
- ❌ Writing values when nothing changed: Do not repeat unchanged variable values on every row! Only record when a value changes.
- ❌ Forgetting 1-based indexing: Cambridge arrays start at index 1, not 0.
- ❌ Missing quotes or text in OUTPUT: Always output the exact printed string including variable values concatenated.
- ❌ Stopping early on FOR loops: Make sure to complete all loop iterations through
NEXT Count.
6. Interactive Trace Table Practice
Ready to test your trace table skills? Use our dedicated Trace Table Practice environment to dry-run exam pseudocode with instant answer checking!
Practice Trace Tables Now
Solve exam-style trace tables, fill matrix values row-by-row, and get real-time feedback with solution explanations.