📁 Paper 1 · 3.1 Fundamentals of Algorithms
3.1.1c Analysing Algorithms — Trace Tables
AQA 8525 · GCSE Computer Science · ~10 min read
Notes
──
Video
──
Slides
──
Worksheet
──
Quiz

Inputs, Processing and Outputs

Every algorithm has three components:

Input
Data supplied to the algorithm (from user, file, sensor, etc.)
Processing
Operations performed on the data (calculations, comparisons, assignments)
Output
Results produced by the algorithm (displayed, stored, returned)

When analysing an algorithm, identify what its inputs, processing steps, and outputs are, then determine its purpose from its structure.

What is a Trace Table?

A trace table (also called a dry run) is a method of manually tracking how variables change as an algorithm executes, line by line. Use it to:

  • Check an algorithm produces the correct output for a given input
  • Find bugs (logic errors) in an algorithm
  • Understand what an algorithm does without running it on a computer

Each column = a variable or an output. Each row = the state after executing one step.

How to Complete a Trace Table

  1. Create a column for each variable and a column labelled OUTPUT
  2. Read the algorithm line by line
  3. When a variable changes, record its new value in the correct column
  4. When OUTPUT is called, record the value in the OUTPUT column
  5. Repeat until the algorithm finishes

Worked Example 1 — Simple Counter (WHILE loop)

x1 WHILE x <= 4 OUTPUT x xx + 1 ENDWHILE
xx ≤ 4?OUTPUT
1True1
2True2
3True3
4True4
5False — STOP

Purpose: Outputs integers 1 to 4.

Worked Example 2 — Finding the Maximum (FOR loop)

nums ← [4, 9, 2, 7] maxValnums[0] // start at first element FOR i1 TO 3 IF nums[i] > maxVal THEN maxValnums[i] ENDIF ENDFOR OUTPUT maxVal
inums[i]maxValnums[i] > maxVal?
4
199True → update
229False
379False

Output: 9   Purpose: Finds and outputs the largest value in the list.

Determining the Purpose of an Algorithm

AQA questions often ask: "State the purpose of this algorithm." Strategy:

  1. Trace the algorithm with the given inputs
  2. Look at the output — what value(s) does it produce?
  3. Look for patterns: counting, summing, finding max/min, searching?
  4. Write one clear sentence: "The algorithm finds the largest value in a list and outputs it."
Exam tip: Show every change — even if a variable stays the same, write its current value in each row. Examiners want to see you tracking it, not just the step where it changes.
⚠️ Common Mistakes
  • Forgetting to check the WHILE condition before entering — the body may never run
  • Off-by-one errors in FOR loops: FOR i ← 1 TO 4 runs 4 times (not 3)
  • Not including a condition column in the trace table — you need it to show why a loop stops
  • Describing the purpose too vaguely — "it does something with numbers" is not enough
Video coming soon
This lesson video is in production

Key points covered in this video

  • Identifying inputs, processing and outputs in any algorithm
  • Setting up a trace table with the right columns
  • Tracing a WHILE loop step by step
  • Tracing a FOR loop with a condition
  • How to state the purpose of an algorithm from its trace
Click slide or press arrow keys to navigate
✍️

Exam-style Worksheet — 3.1.1c Trace Tables

8 AQA-style questions · 22 marks · AI marks your answers and gives feedback

Q1What is a trace table? State one reason for using one.[2 marks]
✅ Mark scheme
Mark scheme
A trace table is a table used to manually track how variable values change as an algorithm executes [1]; used to check correctness / find bugs / determine purpose without running on a computer [1].
Q2Name the three components of every algorithm.[3 marks]
✅ Mark scheme
Mark scheme
Input [1]; Processing [1]; Output [1].
Q3Complete the trace table for x ← 2 / y ← x * 3 / z ← y - 1 / OUTPUT z, with x = 2.[3 marks]
✅ Mark scheme
Mark scheme
y = 6 [1]; z = 5 [1]; OUTPUT 5 [1].
Q4Trace the algorithm with n = 5. State the purpose.

total ← 0
FOR i ← 1 TO n
total ← total + i
ENDFOR
OUTPUT total
[4 marks]
✅ Mark scheme
Mark scheme
i=1→total=1; i=2→total=3; i=3→total=6; i=4→total=10; i=5→total=15 [2 — award 1 if 3+ rows correct]; OUTPUT 15 [1]; Purpose: calculates and outputs the sum of integers from 1 to n [1].
Q5How many times does FOR i ← 0 TO 4 execute its loop body? Write all output values for: FOR i ← 0 TO 4 / OUTPUT i * i / ENDFOR[2 marks]
✅ Mark scheme
Mark scheme
5 times (i = 0, 1, 2, 3, 4) [1]; Output: 0, 1, 4, 9, 16 [1].
Q6Trace with count = 10. State what outputs are produced.

WHILE count > 0
OUTPUT count
count ← count - 3
ENDWHILE
[3 marks]
✅ Mark scheme
Mark scheme
count=10→OUTPUT 10, count←7 [1]; count=7→OUTPUT 7, count←4; count=4→OUTPUT 4, count←1; count=1→OUTPUT 1, count←−2 [1]; count=−2: condition false → STOP. Output: 10, 7, 4, 1 [1].
Q7A trace table shows that a loop variable never changes during the loop. What does this indicate?[2 marks]
✅ Mark scheme
Mark scheme
It indicates a logic error / bug in the algorithm [1]; the loop will run forever (infinite loop) because the variable that controls the condition is never updated [1].
Q8Describe how you would determine the purpose of an unfamiliar algorithm in an exam.[3 marks]
✅ Mark scheme
Mark scheme
Trace the algorithm with the given input values [1]; note the final output value(s) [1]; write a clear statement of what the algorithm does, e.g. "it finds the maximum value in a list" [1].
Compare your answers to the mark schemes above.
Topic Quiz
Question 1 of 15
You scored
out of 15
Card 1 of 6
Click to flip
🎉
All cards reviewed!
TermDefinition
🎯

Mini Test — 3.1.1c Trace Tables

Timed exam conditions. No feedback until you submit.

  • 10 questions · 10 marks · 10 minutes
  • 5 multiple choice + 5 short answer
  • Mark schemes revealed after submission
← 3.1.1b Representing Algorithms
3 of 57 · AQA 8525
3.1.2 Efficiency of Algorithms →