How to Answer Trace Table Questions (OCR A Level Computer Science): Revision Note
Exam code: H446
How do I answer an OCR A Level Computer Science trace table question?
What is a trace table?
Trace tables are used to follow the values of variables as a program runs
These questions test your ability to simulate code line by line and accurately record outputs
Examiner Tips and Tricks
You must read the code carefully and simulate it exactly as a computer would
Use a pencil and annotate each step
The most common mistake is skipping or misreading a line
What you need to know
You may be asked to complete a trace table, explain a trace table, or spot errors in output
These questions are normally worth 3–6 marks
Most commonly appear in questions involving iteration, selection, and arrays/lists
In most cases, the structure of the table is provided, your task is to complete the missing values
Command words to look out for
Command word | What it means |
---|---|
Complete | Fill in the table with correct values |
State | Give the value/output/result (usually a single word or number) |
Explain | Say why something happens or changes in the program |
Identify | Spot where something goes wrong or doesn't match expectations |
How to tackle a trace table question
Follow these steps to answer trace table questions accurately:
Read the code carefully
Understand what each line does
Look out for loops, IF statements, and variable changes
Use the trace table provided
Use the headings and row count to guide how many iterations or steps are neededWork line by line
Simulate the program in your head or on paperUpdate each variable after every change
Watch out for variable resets
Variables declared inside loops often reset every time, don’t carry the wrong value across iterationsShow the final output clearly
If you're asked for the output, make sure it’s written exactly as it would appear on screen
Worked example
Question | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
This algorithm checks whether a list of numbers contains a duplicate:
Complete the trace table below when the algorithm is run You may not need to use all the rows in the table
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 ≠ 7, so no change | |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 ≠ 2, so no change | |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 ≠ 7, so no change | |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 ≠ 7, so no change | |||||||||||||||||||||||||||||||||||||||||||||||||
| 7 = 7 → set | |||||||||||||||||||||||||||||||||||||||||||||||||
| End of loops → output result | |||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| True | |||||||||||||||||||||||||||||||||||||||||||||||||
Final answer | ||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
Examiner Tips and Tricks
You don’t need to fill in
Line 06
(where the assignment happens), just show the change infoundDuplicate
Use a dash (–) when a column isn’t relevant (like
i
,j
after the loops finish)Add a comment column in the margin if you're writing by hand, it helps show your thought process if you make a mistake
Unlock more, it's free!
Did this page help you?