Paper 2 · Trace tables

How to fill a trace table the way the mark scheme does

· 6 min read · For students

A trace table is the program run by hand. Paper 2 pays for that dry run, and the mark scheme is picky about the grid: a column for each variable, a new number only when that variable is assigned, and a blank when it is left alone. Output has its own column.

Take this total. Total starts at 0. Each pass of the loop adds the counter, then the program prints the result.

Right
DECLARE Total : INTEGER
DECLARE i : INTEGER
Total <- 0
FOR i <- 1 TO 3
    Total <- Total + i
NEXT i
OUTPUT Total
Output
6

Filled the examiner way, the grid looks like this. A cell stays blank when that variable did not change on that step.

iTotalOUTPUT
10
1
23
36
6

The first row is the assignments before the loop body does any adding: i becomes 1 and Total is still 0. The next row is Total <- Total + i, so only Total changes. When i moves to 2, Total is updated on the following row, not on the same one. The printed 6 appears once, in the OUTPUT column, on the line that runs OUTPUT.

What usually earns the mark

  • One column per variable the question names, plus OUTPUT if the program prints.
  • Write a value only in the row where it is assigned. Copying the old value into every cell is the mistake the scheme crosses out.
  • Step in order. A FOR loop assigns the counter, then runs the body, then assigns the next counter.
  • Show the output in the OUTPUT column, not squeezed into a variable column.

Check a dry run against a real one

Run the program in the compiler and switch the trace table to Exam style. That layout follows the same rule: a value only when it is assigned, blank when it is unchanged. If your paper grid and that table disagree, the paper grid is the one to fix. The blank trace table lesson is the same drill with the cells empty first.

Check your own code

Run it in the compiler. A mistake is explained in plain English, and many of them have a one-click fix.

More from the blog