SLIDE 1
CSZone.co.uk
Click to advance · Arrow keys also work
AQA 8525 · Section 3.1 · 3.1.1c

Trace
Tables

Dry-running algorithms · Tracking variable values · Spotting errors

CSZone AQA GCSE Computer Science 8525
Learning Objectives

By the end of this lesson you will be able to...

Explain what a trace table is and why it is used
Complete a trace table for a given algorithm, tracking all variable values
Identify the final output of an algorithm by dry-running it
Use trace tables to find bugs in an algorithm
Core Concept

What is a Trace Table?

DEFINITION
A table used to dry-run (manually execute) an algorithm, recording the value of each variable after every step. Used to check whether code produces the correct output without running it on a computer.
COLUMNS
One column per variable + one for output. Header row names each variable.
ROWS
One row per line of code executed (or per iteration of a loop).
Worked Example

Trace This Algorithm

x ← 1
y ← 10
WHILE x < 4
  y ← y - x
  x ← x + 1
ENDWHILE
OUTPUT y
xyOUTPUT
110
29
37
444
Loop ends when x = 4 (not < 4)
Method

How to Complete a Trace Table

Step 1:Create columns — one for each variable that changes, plus an OUTPUT column
Step 2:Work through the algorithm line by line — only update a cell when that variable changes
Step 3:For loops — add a new row for each iteration, updating the relevant values
Step 4:Only write to the OUTPUT column when an OUTPUT statement is executed
Common Mistakes

Errors to Avoid

Filling every cell — only update a variable's column when IT specifically changes
Off-by-one on loops — check whether the condition uses < or ≤ carefully
Forgetting the final OUTPUT — the output column is only updated on OUTPUT statements
⚡ Exam Tip:Trace tables are worth 3–6 marks on AQA Paper 1. Practice until it feels mechanical.
Exam Practice

Complete the trace table

AQA-style question
Trace the algorithm below. Complete the table showing values of a, b, and OUTPUT.

a ← 3
b ← 1
FOR i ← 1 TO 3
  b ← b * a
ENDFOR
OUTPUT b
3 marks
ANSWER: b = 3, 9, 27 → OUTPUT: 27
Each iteration: b = b × 3. After 3 iterations: 1 × 3 × 3 × 3 = 27
Key Takeaways

What to Remember

A trace table manually executes an algorithm and records variable values at each step
Columns = one per variable + OUTPUT. Rows = one per executed line (or loop iteration)
Only update a cell when that specific variable changes
Trace tables help find logic errors — the output tells you if the algorithm is correct