9618/31 May/June 2023 · Question 2(b) · 2 marks
Describe the purpose of both the A* algorithm and Dijkstra's algorithm.
Points that gain marks
- Both find the best (shortest or cheapest) route between two nodes in a graph.
- The best route is measured by distance, cost or time on the edges.
In this lab: On the grid every step costs 1, so BFS works like Dijkstra here: it finds a shortest route. A* finds a route just as short but visits fewer squares, because h points it at the end.