Algorithm Tracing Practice
Practise tracing pseudocode and Python by hand
What the Research Says
Algorithm tracing is a skill that improves with deliberate practice. Research on programming education shows that students who regularly trace code by hand develop stronger mental models of program execution, leading to fewer bugs and better exam performance.
Evidence Base
| Study | Finding | Impact |
|---|---|---|
| Lister et al. (2004) | Students who cannot trace code accurately also cannot write code. Tracing is a prerequisite skill. | Foundation for coding |
| Ericsson (2006) | Deliberate practice — focused, repetitive, with feedback — is the key to developing expertise. | Skill mastery |
| Lopez et al. (2008) | Students who practised tracing scored significantly higher on programming exams than those who only wrote code. | Better exam scores |
Step-by-Step Method
- 1Find or write a short program — Start with 5–10 lines of code involving loops, selection, and variables. Use OCR pseudocode or Python.
- 2Draw a trace table — One column per variable, plus an output column. Label each column clearly.
- 3Execute line by line — Point to each line with your finger or pencil. Update the trace table after each assignment or output.
- 4Check against a computer — Type the code into Python and run it. Does your traced output match? If not, find where you went wrong.
- 5Increase difficulty — Progress from simple loops to nested loops, then to programs with arrays and functions. Time yourself to build speed.
Trace: total = 0; for i = 1 to 5: total = total + i. Your trace table should show i going from 1 to 5 and total going 1, 3, 6, 10, 15.
Trace a linear search through the array [4, 7, 2, 9, 1] looking for the value 9. Track the index variable and the comparison result at each step.
Trace one pass of bubble sort on [5, 3, 8, 1]. Show each comparison and swap. After one pass the array should be [3, 5, 1, 8].
Common Pitfalls
- Skipping steps — Write every variable change, even obvious ones. The exam awards marks per row.
- Only tracing simple programs — If you only practise easy traces, nested loops and functions will trip you up in the exam.
- Not checking against a computer — Without feedback, you may reinforce wrong habits. Always verify.
When to Use This
Trace 2–3 programs per revision session, 3 times a week. Start 6–8 weeks before the exam. In the final 2 weeks, trace past paper algorithms under timed conditions.