📁 Paper 1 · Topic 1: Computational Thinking
1.2f Trace Tables
Edexcel 1CP2 · GCSE Computer Science · ~12 min read · 🔒 Pro
Notes
──
Video
──
Slides
──
Worksheet
──
Quiz

What is a Trace Table?

A trace table is a technique used to manually track the value of variables and conditions at each step of an algorithm. It is used to check whether an algorithm produces the correct output and to find any errors.

Each column in the trace table represents one variable (or output/condition). Each row represents one iteration or line of the algorithm being executed.

How to Complete a Trace Table

  1. Write a column for each variable used in the algorithm, plus any outputs or conditions.
  2. Execute the algorithm line by line, filling in the current value of each variable at each step.
  3. Only write a new value in a column when that variable changes.
  4. At the end, check the output matches what is expected.

Worked Example

Trace the following algorithm for n = 4:

total ← 0
i ← 1
WHILE i ≤ n DO
    total ← total + i
    i ← i + 1
ENDWHILE
OUTPUT total
Steptotalii ≤ n?Output
Start01
Iteration 112True
Iteration 233True
Iteration 364True
Iteration 4105False10

The algorithm outputs 10, which is 1+2+3+4 = 10. Correct!

Using Trace Tables to Find Errors

If the trace table shows an unexpected value, a logic error has been found. For example, if the output above was 9 instead of 10, you could trace back through the table to find which step went wrong.

Exam tip: In Edexcel exams, trace table questions are worth 3–6 marks. Write values neatly in every cell. Only write a new value when a variable actually changes. Do not leave cells blank where a value remains the same — either repeat the value or leave it blank only if the variable hasn't been assigned yet. Check your final output row carefully.
⚠️ Common Mistakes
  • Not updating a column when a variable changes — missing key trace steps
  • Adding an extra iteration (loop runs one too many or too few times)
  • Forgetting to add a column for conditions (e.g., i ≤ n) when asked for them
  • Writing what you think the answer should be rather than following the algorithm exactly
Video coming soon
In production

Key points

  • What trace tables are and why we use them
  • Step-by-step: how to complete a trace table
  • Full worked example with a WHILE loop
  • Using trace tables to identify logic errors
  • Exam technique for trace table questions
Click slide or press arrow keys to navigate
✍️

Worksheet — 1.2f Trace Tables

8 Edexcel-style questions · AI-marked

Q1What is the purpose of a trace table?[2]
✅ Mark scheme
To track the value of variables at each step of an algorithm [1] to check the algorithm produces the correct output / find logic errors [1].
Q2State what each column in a trace table typically represents.[1]
✅ Mark scheme
Each column represents one variable (or output/condition) in the algorithm. [1]
Q3Complete a trace table for the following algorithm with input x = 3. Columns: x, result, output.
result ← 1 / i ← 1 / WHILE i ≤ x / result ← result * i / i ← i + 1 / ENDWHILE / OUTPUT result
[4]
✅ Mark scheme
Row 1: i=1, result=1 [1]; Row 2: i=2, result=2 [1]; Row 3: i=3, result=6 [1]; Output: 6 [1]. (Algorithm computes 3! = 6)
Q4When should you write a new value in a column of a trace table?[1]
✅ Mark scheme
Only when that variable's value changes / is updated. [1]
Q5A student's trace table shows the loop running 5 times for a 4-item list. What type of error does this suggest?[2]
✅ Mark scheme
A logic error [1] — specifically an off-by-one error where the loop condition is incorrect (e.g., ≤ instead of <) [1].
Q6Trace the following for n=5 and x=2. State the output.
result ← x / i ← 1 / WHILE i < n / result ← result * x / i ← i + 1 / ENDWHILE / OUTPUT result
[3]
✅ Mark scheme
i=1: result=4 [1]; i=2: result=8; i=3: result=16; i=4: result=32 [1]; Output: 32 (= 2^5) [1].
Q7Describe how you would use a trace table to find a logic error in an algorithm.[3]
✅ Mark scheme
Execute the algorithm line by line, recording each variable value in the trace table [1]; compare the expected output with what the trace table shows [1]; identify which step produces an unexpected value — that step contains the logic error [1].
Q8Trace the following algorithm for the list nums = [3, 1, 4, 1, 5]. Show the values of i, nums[i] and total at each step. State the final output.
total ← 0 / FOR i ← 0 TO 4 / total ← total + nums[i] / NEXT i / OUTPUT total
[4]
✅ Mark scheme
i=0: nums[0]=3, total=3 [1]; i=1: nums[1]=1, total=4; i=2: nums[2]=4, total=8; i=3: nums[3]=1, total=9 [1]; i=4: nums[4]=5, total=14 [1]; Output: 14 [1].
Topic Quiz
Q 1 of 15
You scored
out of 15
⚡ XP
Click to reveal definition
🎉
Session complete!
TermDefinition
🎯

Mini Test — 1.2f Trace Tables

Timed exam-style test. No feedback until submission.

  • 10 questions · 10 marks · 10 minutes
← 1.2e Designing AlgorithmsTopic 1Next: 1.2g Testing →
🔒

Unlock Pro

Subscribe to access all 59 Edexcel 1CP2 lessons.

£7.99/month
or £59/year
Subscribe →