Tracing A* and comparing it with Dijkstra – OCR A Level Computer Science lesson (H446)
Students learn to trace A* to the goal, explain why it stops only when the goal is chosen and why its heuristic must not overestimate.
Lesson 5 of 17 in unit 13.4 Path-finding, Computational Methods and Project Development, taught in Year 13, Autumn 2. It answers one big question: When can you trust A* to give the shortest route?
By the end, students can trace A* to the goal, explain why it stops only when the goal is chosen and why its heuristic must not overestimate.
- The Build (the main task)
- Trace the A* algorithm from G to P on Harrowgate Fulfilment's warehouse floor graph with the given heuristic, recording g, h and f for each node in the open list after every expansion, then distinguish between A* and Dijkstra's algorithm in how they choose the next node and when they stop.
- Support version
- A trace table with the expansion order given and the first two rows filled in, and a 'whereas' frame for the distinguish part.
- Challenge
- D's heuristic is changed from 2 to 9. Trace A* again and explain why it now returns a route that is not the shortest.
- Real-world link
- Harrowgate Fulfilment checks its planner's estimates after a new mezzanine is added, because a wrong estimate sends robots the long way round.
- Key words
- Admissible heuristic, Goal node and Distinguish, each with a definition, an icon and a common mix-up on the key vocabulary slide.
- Misconceptions it tackles
- “A* can stop as soon as the goal appears as a neighbour”; “Any heuristic estimate will give the shortest route”.
- OCR H446 specification
- 2.3.1 (f) (standard algorithms: here Dijkstra's shortest path algorithm and the A* algorithm, traced on weighted graphs and compared (the searching and sorting algorithms in this point were taught in 12.4)).
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.
Students can do it all on paper.
Also sold in the Path-finding, Computational Methods and Project Development unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.
An independent resource written for OCR A Level Computer Science (H446). It is not endorsed by OCR or Cambridge University Press & Assessment. Programming project (NEA) lessons teach general skills on a made-up example project and give supervised time, within JCQ's rules on the help a centre may give.
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 A Level Computer Science
See allStudents learn to describe how Dijkstra's algorithm finds the shortest path in a weighted graph and why each step keeps the lowest total.
Free sample lessonStudents learn to trace Dijkstra's algorithm with a priority queue, recording each distance and previous node, and read the path back from the goal.
Students learn to plan sprint 2 from their design and review of sprint 1, and write modular, annotated code with dated journal entries.
Written for the specifications named. Not endorsed by or affiliated with any exam board.