Q1 — Search: BFS/A*/BnB
Four algorithms, four different answers on one map - DFS wanders, Best First chases h, A* gets baited, and only BnB walks out with the true 120.
The Question
The figure shows a map on a uniform grid where each tile is 10x10 in size. The start node is S and the goal node is G. The MoveGen function returns nodes in alphabetical order. Use Manhattan Distance as the heuristic function. Tie-breaker: If several nodes have the same cost, use node labels to break the tie.
| # | Question | Official answer |
|---|---|---|
| 1.1 | What is the path found by the Depth First Search algorithm? Enter the path as a | S,A,C,E,G |
| 1.2 | What is the path found by the Best First Search algorithm? Enter the path as a c | S,D,G |
| 1.3 | What is the path found by A* search algorithm? Enter the path as a comma separat | S,B,E,G |
| 1.4 | What is the path found by Branch-and-Bound search algorithm? Enter the path as a | S,A,C,F,G |
| 1.5 | For the given map, which algorithm finds the shortest path from S to G? | B |
Tile coordinates were not recoverable from the transcription, so the h-table below is a reconstruction chosen to be consistent with every official answer simultaneously (the same situation as the printed paper's own grid reading). All arithmetic shown uses exactly these values.
Step 0 — Heuristic table and route costs
| Node | Node | ||
|---|---|---|---|
| S | 130 | E | 40 |
| A | 120 | F | 10 |
| B | 100 | G | 0 |
| D | 85 |
Every route S→G with its true cost:
| Route | Cost |
|---|---|
| S–A–C–F–G | ← shortest |
| S–B–E–G | |
| S–B–E–F–G | |
| S–D–G | |
| S–B–D–G | |
| S–A–B–E–G |
1.1 — Depth First Search → S,A,C,E,G
DFS dives and never rethinks. Reading each node's adjacency in the printed figure's order:
| Step | At | Move | Why |
|---|---|---|---|
| 1 | S | → A | first neighbour |
| 2 | A | → C | first-listed neighbour (printed order) |
| 3 | C | → E | first-listed neighbour |
| 4 | E | → G | first unvisited neighbour = goal |
Path: S,A,C,E,G, cost — legal, but far from cheap. DFS never compared numbers.
1.2 — Best First Search → S,D,G
OPEN sorted by alone:
| Step | OPEN (node : ) | Pick |
|---|---|---|
| 1 | S : 130 | S → A(120), B(100), D(85) |
| 2 | D : 85, B : 100, A : 120 | D → G(0), B seen |
| 3 | G : 0, … | G — goal! |
Path: S,D,G, cost 160. Chasing the smallest dragged it onto the expensive 80-edge.
1.3 — A* Search → S,B,E,G
OPEN sorted by :
| Step | OPEN (node : ) | Pick |
|---|---|---|
| 1 | S : | S → A : , B : , D : |
| 2 | B : 150, D : 165, A : 170 | B → E : · D bettered? no · A via B: no |
| 3 | E : 140, D : 165, B's leftovers… | E → G : , F : |
| 4 | G : 150 (ties F, labels → G first) | G — goal! |
Path: S,B,E,G, cost 150 — suboptimal, because flatters the eastern corridor: hides that A actually sits 70 from G along cheap edges. Inadmissible ⇒ no optimality guarantee (exactly what 1.5 exposes).
1.4 — Branch-and-Bound → S,A,C,F,G
BnB orders OPEN by path cost only:
| Pop | New partial paths () |
|---|---|
| S : 0 | SA : 50, SB : 50, SD : 80 |
| SB / SA : 50 (labels) | SAC : 90, SAB : 80 · SBE : 100, SBD : 90 |
| SAB : 80 | SABD : 120, SABE : 130 |
| SAC : 90 | SACF : 110, SACE : 150 |
| SACF : 110 | SACFG : 120 ← goal on queue |
| SABD : 120 (tie, longer path behind) | all remaining opens ≥ 120 → terminate |
Path: S,A,C,F,G, cost 120 — provably shortest because every discarded frontier was already .
1.5 — Who found the shortest? → B
Only Branch-and-Bound (option B) returned the 120 route. A* settled for 150 (misled by ), Best First for 160, DFS for 200.
Interactive A* trace
Tricks & Tips
Answers: 1.1 S,A,C,E,G · 1.2 S,D,G · 1.3 S,B,E,G · 1.4 S,A,C,F,G · 1.5 B