OCR GCSE Computer Science · Component 2

📋 Trace Table Challenge

Step through code and track how variables change — or hunt down the errors

Score 0
Level 1 / 4
Question 1 / 3
📋

What is a Trace Table?

A trace table is a technique used in computer science exams to check that you understand exactly what a piece of code does — step by step, line by line.

The idea

When code runs, variables change their values. A trace table tracks those changes. You get one column per variable and one row per line of code that changes something. You fill in the new value only when it changes — leave the cell blank otherwise.

Example

x ← 4
y ← 2
x ← x + y
x y
Line 1 4 —
Line 2 — 2
Line 3 6 —

Line 3: x = 4 + 2 = 6. y didn't change, so leave it blank.

The rules

  • 1️⃣Only write a value in a cell when that line changes that variable. Leave other cells empty.
  • 2️⃣Variables keep their last value until a new line changes them.
  • 3️⃣For loops: one row per iteration. Watch accumulator variables build up.
  • 4️⃣For IF statements: only trace the branch that actually runs. The other branch is skipped.
  • 5️⃣Go slowly. One line at a time. This is not a speed test.

Two modes

✏️ Fill in

Some cells are blank. Read the code, work out the value, type it in. Green = correct, red = wrong.

🔍 Error Hunt

The table is already filled in — but some values are wrong. Click the cells you think are mistakes, then check.

Scoring

  • 🏆10 points for a perfect answer without using a hint.
  • 💡5 points if you used the hint — still worth trying!
  • 🔒Complete each level to unlock the next one.

🎉