Skip to main content

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

By Prof. David Chen, CS Examiner·Updated April 18, 2026
A large empty trace table grid with variable names as column headers.

How do you get full marks on a Paper 2 Trace Table question?

Do not skip steps. Cross out old values mentally, but write the new values on the next available line in the grid. Never write two different values for the same variable on the exact same horizontal row. Only write in the OUTPUT column when the exact word 'OUTPUT' appears in the pseudocode. Follow the loop exactly as written, even if you realize the code is creating an infinite loop!

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).

💡 Tutor's Tip
The Inner Loop Reset: The biggest mistake students make is failing to "reset" inner loops. If the Outer loop runs 3 times, and the Inner loop runs 5 times... the inner loop runs 5 times, finishes, the outer loop advances by 1, and the inner loop begins AGAIN from 1 to 5. The total executions will be 15. Track your loop counters carefully!

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?
A manual tracking grid used by programmers to dry-run code and spot logic errors by recording the changing values of variables.
When do you start a new row in a trace table?
Usually when the loop iterates back to the top, or when a heavily used variable changes value for a second time in one sequence.
What is an OUTPUT column?
The column strictly reserved for text/data generated by an OUTPUT or PRINT command in the pseudocode.
Are trace tables used to find syntax errors?
No, they find Logic errors. Syntax errors are grammar mistakes that prevent code from turning on. Logic errors happen while the code is running.

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.

Related Computer Science Articles