Trace tables and refining algorithms – OCR GCSE Computer Science lesson (J277)
Pupils learn to complete a trace table for an algorithm, use it to locate a logic error, and refine the algorithm with the smallest change that fixes it.
Lesson 7 of 11 in unit 11.3 Impacts of Technology and Full Papers, taught in Year 11, Spring 1. It answers one big question: How do you find and fix an error you can't see?
By the end, pupils can complete a trace table for an algorithm, use it to locate a logic error, and refine the algorithm with the smallest change that fixes it.
- The Build (the main task)
- Complete the trace table for TapRide's daily-cap algorithm, which should add up a passenger's fares for the day and charge no more than £5 – passengers say it charges the wrong amount. Then identify the line that contains the logic error, and refine the algorithm by rewriting that line so it gives the correct total.
- Support version
- Part-filled trace table, first two rows done, with a hint about the loop.
- Challenge
- Write test data that would find the error; explain why tracing finds logic, not syntax, errors.
- Real-world link
- Passengers complain that TapRide charged them the wrong amount for the day, so the developers trace the daily-cap algorithm.
- Key words
- Trace table, Logic error and Refine, each with a definition, an icon and a common mix-up on the key vocabulary slide.
- Misconceptions it tackles
- “A logic error stops the program from running”; “A trace table only records the final value of each variable”.
- OCR J277 specification
- 2.1.2; 2.3.2.
Every lesson follows the same Code & Commerce structure: a Bell Task recall starter, key vocabulary with definitions and icons, short teaching chunks with a check before pupils move on, The Build (one main task), challenge questions that get harder, and an exit question. Answers reveal one at a time on the slides, and everything is editable PowerPoint and Word.
Pupils can do it all on paper.
Also sold in the Impacts of Technology and Full Papers unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.
What's included
- Slide deck (PowerPoint)
- Lesson plan (Word)
- Worksheet (Word)
- Support worksheet with scaffolds (Word)
- Single-teacher licence: use and adapt it with your own classes
More for GCSE Computer Science (OCR)
See allPupils learn to identify the stakeholders of a technology and explain ethical issues it raises for different stakeholders, separating what is right from what is legal.
Pupils learn to describe what the Data Protection Act 2018, Computer Misuse Act 1990 and Copyright, Designs and Patents Act 1988 control, and say which applies to a scenario.
Pupils learn to compare open source and proprietary software, explain what a licence allows, and recommend one for a given use with a reason.
Written for the specifications named. Not endorsed by or affiliated with any exam board.