본문 바로가기

Labs · AI search · BFS, DFS, A*

Search the Maze: BFS, DFS and A*

Build walls, then race four searches from S to E. Watch breadth-first spread like a wave, depth-first dive deep, and A* head straight for the end.

4 levelsFree bench

In the exam

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.

9618/32 May/June 2026 · Question 9(b)(i) · 3 marks

The A* and Dijkstra's algorithms are used to perform searches on a graph. Outline how the A* algorithm is different from Dijkstra's algorithm.

Points that gain marks

  • A* tries to find the shortest path using heuristics (intelligent guesses).
  • A* does not necessarily pass through all the nodes or paths.
  • Dijkstra's algorithm finds the shortest path to all the nodes, checking each vertex.
  • Dijkstra's algorithm always finds the shortest path.

In this lab: Level 2 shows both: A* heads for E and visits far fewer squares, while BFS (Dijkstra on a grid, where every step costs 1) spreads out in every direction. Level 4 shows the catch: with a guess that is too big, A* is no longer sure to find the shortest path.

More real experiments

All labs →

로그인 또는 계정 만들기

IGCSE, A-Level & AP