Q1 — Best First Search, A* and Branch-and-Bound on the Grid Map

A tie between C and D decides Best First Search, A* settles for 5, and only Branch-and-Bound uncovers the hidden cost-4 route.

The Question

1×1-tile grid. Start S (top), goal G. MoveGen alphabetical. Heuristic = Manhattan Distance. Tie-breaker: node labels.

#QuestionOfficial answer
1.1Best First Search pathS,B,C,G
1.2A* pathS,B,D,G
1.3Branch-and-Bound pathS,A,E,F,G
1.4Who finds the shortest path?B — Branch-and-Bound only
1.5AdmissibilityB — not admissible

The Topic in 60 Seconds

AlgorithmSorts OPEN byIgnores
Best Firsth(n)h(n)g(n)g(n)
A*f(n)=g(n)+h(n)f(n) = g(n) + h(n)nothing
Branch-and-Boundg(n)g(n)h(n)h(n)

Deep-dive: A* Search, Best First Search, Branch and Bound.

Step 0 — Heuristic table (Manhattan to G)

NodehhNodehh
S4D2
A5E5
B2F3
C2G0

1.1 — Best First Search → S,B,C,G

StepOPEN (node : hh)Pick
1S : 4S → A(5), B(2)
2B : 2, A : 5B → D(2), C(2)
3C : 2, D : 2, A : 5C (tie with D → label order!)
4G : 0, D : 2, A : 5G — goal!

Path: S → B → C → G. The C-vs-D tie at h=2h = 2 is the whole question — labels send the search to C.

1.2 — A* → S,B,D,G

StepOPEN (node : ff)Pick
1S : 0+4 = 4S → A : 1+5 = 6, B : 2+2 = 4
2B : 4, A : 6B → D : 3+2 = 5, C : 4+2 = 6
3D : 5, A : 6, C : 6D → F : 4+3 = 7, G : 5+0 = 5
4G : 5, A : 6, C : 6, F : 7G — goal!

Path: S → B → D → G, cost 2+1+2=52+1+2 = 5. (Not optimal — see 1.5.)

1.3 — Branch-and-Bound → S,A,E,F,G

PopOPEN (path : gg)Extend
S : 0SA : 1, SB : 2
SA : 1SAE : 2, SAD : 4
SAE : 2 (tie with SB — S-A before S-B)SAEF : 3
SB : 2SBD : 3, SBC : 4
SAEF : 3 (tie with SBD — S-A before S-B)SAEFG : 4 ← goal queued
SBD : 3SBDA : 3+33+3 = 6, SBDF : 3+13+1 = 4, SBDG : 3+23+2 = 5, SBDC : 3+23+2 = 5
SAD : 4 (first of the four-way tie at 4 — labels)SADF : 4+14+1 = 5, SADG : 4+24+2 = 6
SAEFG : 4 — next at the tie, a complete toureverything left ≥ 4 → optimal

Path: S → A → E → F → G, cost 1+1+1+1=41+1+1+1 = 4 ✓ the true shortest path.

1.4 — Shortest path → B (Branch-and-Bound only)

Routes: S-A-E-F-G = 4 · S-B-D-G = 5 · S-B-C-G = 6 · S-A-D-G = 6. A* returned 5, BnB returned 4 → B.

1.5 — Admissibility → B (not admissible)

h(A)=5h(A) = 5 but the true cheapest cost from A is A→E→F→G=3A \to E \to F \to G = 3 — overestimate! → not admissible → B. (Exactly why A* missed the optimal path in 1.4.)

Interactive A* trace

1 / 5
OPEN = { S(g=0, h=4, f=4) }
expandingin OPEN (f = g+h)expandedreturned path

Tricks & Tips

Answers: 1.1 S,B,C,G · 1.2 S,B,D,G · 1.3 S,A,E,F,G · 1.4 B · 1.5 B