Lesson overview
Follow an algorithm line by line and record how variables change.
Focus: Trace tables and dry runs.
What you will learn
- Use a trace table to record variable values.
- Dry run pseudocode line by line.
- Identify output from a traced algorithm.
- Spot logic errors using test data.
Before you start
- Variables and assignment in simple pseudocode.
- Basic arithmetic.
- Reading conditions such as less than and equal to.
Trace practice
Use the small algorithms below to practise recording variable values after each assignment or loop pass.
Trace tables and dry runs infographic

Explanation
A dry run means manually following an algorithm as if you were the computer. You do not guess the output; you work through each instruction.
A trace table records variables in columns. Each row usually represents a meaningful step, such as after an assignment or at the end of a loop pass.
Trace tables are especially useful when a loop changes a total, counter or position. They make hidden changes visible.
Worked examples
Running total
total = 0
FOR n FROM 1 TO 3
total = total + n
Answer: The total values after each loop pass are 1, 3 and 6.
Quick checks
1. What should you do when an assignment changes a variable during a trace?
- a. Update the variable value in the table
- b. Ignore it until the end
- c. Delete the whole row
Reveal answer
Answer: a. Correct. A trace table tracks changing values.
Not quite. Assignment changes the stored value.
2. Why is test data useful with a dry run?
- a. It makes syntax irrelevant forever
- b. It gives values to follow through the algorithm
- c. It removes the need for variables
Reveal answer
Answer: b. Correct. Test data lets you check a specific path through the logic.
Not quite. Test data helps you follow and check behaviour.
Practice
1. x starts at 2. The line x = x + 5 runs once. What is x?
Reveal answer
Answer: 7.
Marking: Credit replacing x with the old value, then assigning the new value.
2. A loop adds 2 to total three times. total starts at 0. What is total at the end?
Reveal answer
Answer: 6.
Marking: Credit 0 -> 2 -> 4 -> 6.
3. Name two columns a trace table might include.
Reveal answer
Answer: Line number and variable values, such as count and total.
Marking: Credit any sensible variable columns plus step or output columns.
4. How can a trace table reveal a logic error?
Reveal answer
Answer: It shows where values change in an unexpected way or where the wrong branch is followed.
Marking: Credit using the table to locate incorrect behaviour.
Exam practice ladder
- Fluency: recall the key term and use it accurately.
- Application: apply the idea to the scenario rather than giving a generic definition.
- Algorithmic reasoning: show the steps, condition or variable change clearly.
- Evaluation: explain why one method, structure or control is suitable.
Answers and marking guidance
Exact answers and marking guidance are hidden under each question. For this lesson, earn marks by naming the correct Computer Science idea, applying it to the scenario and showing the logic or value change clearly.
Common mistakes
- Writing only the final answer without showing intermediate values.
- Using the new value of a variable too early.
- Skipping loop passes.
- Forgetting that conditions decide which branch runs.
Extension
Trace an algorithm that counts how many numbers in a list are greater than 10.
Next lesson
Next, continue with Input, Processing and Output.
Exam-board guidance
Aplailasain is an independent learning resource and is not endorsed by any exam board.
AQA GCSE Computer Science
AQA GCSE Computer Science: this skill supports problem solving, clear algorithms and accurate programming explanations.
OCR GCSE Computer Science
OCR GCSE Computer Science: expect precise algorithm reasoning, trace work and careful use of programming vocabulary.
Pearson Edexcel GCSE Computer Science
Pearson Edexcel GCSE Computer Science: practise explaining the method as well as giving the final answer or code.
Eduqas GCSE Computer Science
Eduqas GCSE Computer Science: secure the transferable idea first, then check how your class applies it in tasks.
WJEC Wales
WJEC Wales: use accurate terminology and show enough working for the examiner to follow your logic.
CCEA
CCEA: connect the idea to your class route and use the same algorithm, programming or systems vocabulary your teacher uses.