Revise Computing
Revision notesQuestionsFor schools
Log inStart revising free
Revision notesQuestionsFor schoolsLog in
GCSE Computer Science/Paper 2/Designing, creating and refining algorithms

Trace tables

2.1.2 Designing, creating and refining algorithms

Practise exam questions

Designing, creating and refining algorithms — Note 7 of 7

Create and use trace tables to follow an algorithm

What you need to know

A trace table is used to track the values of variables as an algorithm runs step by step. Each row represents one step of execution, and each column represents a variable. Trace tables help you understand what an algorithm does, check for logic errors, and predict the output of a program without actually running it.

What to know

  • Trace tables have a column for each variable in the algorithm and a column for any output.
  • Each row shows the values after one instruction or iteration has been executed.
  • They are especially useful for tracing through loops to see how values change each iteration.
  • Trace tables help identify logic errors by revealing unexpected variable values.
  • You may be asked to complete a trace table for a given algorithm in the exam.
  • Work through the algorithm line by line, updating values in the table as you go.

Exam technique

  • Tip:Leave the output column BLANK if nothing is printed on that line. Writing "x" or "-" is ambiguous and may lose marks.
  • Tip:Include the correct line number for each change. Line number errors are penalised once, then follow-through is applied.
  • Tip:If a variable does not change on a line, you can either leave it blank or repeat the current value.
  • Tip:Outputs must be exact. For print("The score is", score), the output is 'The score is 4' — not just 4. Do NOT include the comma from the print statement.
  • Example:Tracing staffID = surname + str(year), while staffID.length < 10: staffID = staffID + "x". With 'Kofi' and 2021: Kofi2021 → Kofi2021x → Kofi2021xx. Output on print line: 'ID Kofi2021xx'.
  • Example:Tracing while c < 100: c = c * 10. With c = 9: c becomes 90, then 900. Careful with loop bounds — the loop stops when the condition is False.

Code examples

Algorithm to trace
python
# Trace this algorithm:
x = 1
for i in range(1, 4):
    x = x * i
    print(x)

# Trace table:
# i  |  x  | Output
# ---|-----|-------
# 1  |  1  |  1
# 2  |  2  |  2
# 3  |  6  |  6

Ready to test yourself?

Practise 2.1.2 questions
← Previous noteCommon errors2.1.2 Designing, creating and refining algorithmsNext topic →Binary search2.1.3 Searching and sorting algorithms

Back to Designing, creating and refining algorithms

Revise another OCR GCSE topic: Searching and sorting algorithms, Computational Thinking

Designing, creating and refining algorithms

Note 7 of 7

  1. 1The inputs, processes, and outputs for a problem
  2. 2Structure diagrams
  3. 3Pseudocode
  4. 4Flowcharts
  5. 5Reference language/high-level programming language
  6. 6Common errors
  7. 7Trace tables
Topic overview

© 2026 Revise Computing · revisecomputing.co.uk

Privacy noticeTermsContact

Revise Computing is an independent revision resource. It is not affiliated with, or endorsed by, OCR (Oxford Cambridge and RSA Examinations).