Conquering Trace Tables: How to 'Dry Run' Like a CPU

How do you get full marks on a Paper 2 Trace Table question?
Table of Contents
Trace tables are usually the highest single-mark questions on Paper 2. They require zero memorization, only extreme patience and attention to detail. This guide from our Ultimate O-Level Computer Science Guide teaches you how to systematically walk through the code without getting lost.
1. The Purpose of a Dry Run
When a programmer writes an algorithm, it might compile perfectly (zero syntax errors). But when they run it, a calculation comes out totally wrong. This is a Logic Error.
To find exactly which line of code is causing the bad math, the programmer prints out a table and acts like the Central Processing Unit. They execute the code line by line using a pencil, updating the variable values in the grid. This manual execution is called a Dry Run.
2. The 3 Golden Rules of Trace Tables
Examiners are strict about how the table is filled out. If your final output is correct, but your middle rows are a mess, you will lose marks.
Rule 1: One Change Per Column
If Variable A becomes 5, write 5. If later in the same loop, Variable A is multiplied to become 10, DO NOT cross out the 5. Move down to the next row in the grid and write 10. The table must show the history of the variables.
Rule 2: Don't Repeat Unchanged Values
If Variable B stays as '7' for three loops in a row, do not write 7, 7, 7 all the way down the column. Leave the boxes blank. A blank box implies the variable has not changed since the last number written above it.
Rule 3: Guard the Output Column
Only write in the OUTPUT column when the code says OUTPUT or PRINT. Do not write your own personal notes or intermediate math here. Write exactly what the code tells you to output (including treating text in "quotes" literally).
3. Common Exam Traps (Nested Loops)
The hardest trace tables involve nested loops (a FOR loop inside another FOR loop).
The "Bad Code" Trap
Sometimes, CAIE will give you an algorithm that contains a deliberate, fatal logic error (like an infinite loop, or crashing on a negative index). Your job is to trace the table EXACTLY as the bad code demands. Do not "fix" the code in your head and trace the fixed version. Trace the bad code until it crashes, and THEN answer the follow-up question asking "What is the logic error in this algorithm?"
Frequently Asked Questions
What is a trace table?▼
When do you start a new row in a trace table?▼
What is an OUTPUT column?▼
Are trace tables used to find syntax errors?▼
Stop Guessing, Start Scoring
Get instant access to 500+ CAIE-aligned practice questions, worked solutions, and AI-powered mock exams across all O-Level subjects.