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

Best First and A* both get baited right, while Branch-and-Bound assembles the cost-14 northern chain S,A,B,D,G.

The Question

1×1 grid, start S, goal G. MoveGen alphabetical, Manhattan heuristic, ties by label.

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

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, read off the paper's grid)

NodehhNodehh
S6E8
A14H4
B4I6
C8D2
F6G0

Build this before tracing — every subquestion reads from it.

1.1 — Best First Search → S,F,H,G

Sort by hh only:

StepOPEN (node : hh)Pick
1S : 6S → F(6), A(14)
2F : 6, A : 14F → C(8), H(4), I(6)
3H : 4, I : 6, C : 8, E : 8, A : 14H → D(2), E(8), G(0)
4G : 0, D : 2, …G — goal!

Path: S → F → H → G. The tiny hh(H) = 4 sucks the search into the expensive 10-edge crossing before the cheap north chain is even considered.

1.2 — A* → S,F,I,G

StepOPEN (node : ff)Pick
1S : 0+6 = 6S → F : 6+6 = 12, A : 8+14 = 22
2F : 12, A : 22F → I : 12+6 = 18, C : 12+8 = 20, H : 16+4 = 20
3I : 18, C : 20, H : 20, A : 22I → G : 18+0 = 18
4G : 18, C : 20, H : 20, A : 22G — goal!

Path: S → F → I → G, cost 6+6+6=186+6+6 = 18. The killer: going north through A would need expanding A, but h(A)=14h(A) = 14 inflates f(A)f(A) to 22 — A sits at the bottom of OPEN while G pops at 18.

Step through the trace exactly as you would annotate the exam paper:

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

1.3 — Branch-and-Bound → S,A,B,D,G

BnB sorts full paths by gg (ties broken by discovery order), never trusting hh:

PopOPEN (path : gg)Extend
S : 0SF : 6, SA : 8
SF : 6SA : 8, SFC : 12, SFI : 12, SFA : 14, SFH : 16
SA : 8SAB : 10, SFC : 12, SFI : 12, SAC : 14, SAF : 14, SFH : 16
SAB : 10SFC : 12, SFI : 12, SABD : 12, SAC : 14, SAF : 14, SFH : 16, SABC : 16
SFC : 12SFI : 12, SABD : 12, SAC : 14, SAF : 14, SFCE : 16, SFH : 16, SABC : 16, SFCA : 18, SFCB : 18
SFI : 12SABD : 12, SAC : 14, SAF : 14, SFCE : 16, SFH : 16, SABC : 16, SFIG : 18 ← goal, SFCA : 18, SFCB : 18, SFIH : 18
SABD : 12SAC : 14, SAF : 14, SABDG : 14 ← goal, SFCE : 16, SFH : 16, SABC : 16, SABDE : 16, … , SABDH : 20
SAC : 14SAF : 14, SABDG : 14, SFCE : 16, … , SACE : 18, SACF : 20, SACB : 22
SAF : 14SABDG : 14, SFCE : 16, … , SAFC : 20, SAFI : 20, SAFH : 24
SABDG : 14everything open ≥ 16 → optimal

Path: S → A → B → D → G, cost 8+2+2+2=148+2+2+2 = 14 ✓ the true shortest.

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

AlgorithmPathCost
Best FirstS,F,H,G6+10+8=246+10+8 = 24
A*S,F,I,G6+6+6=186+6+6 = 18
Branch-and-BoundS,A,B,D,G8+2+2+2=148+2+2+2 = \mathbf{14}

A* returned 18, BnB returned 14 → C.

1.5 — Admissibility → B (inadmissible)

hh is admissible iff it never overestimates. Check the nodes on the true best route:

Nodeh(n)h(n)True cheapest h∗(n)h^*(n)Verdict
A14A→B→D→G = 2+2+2=62+2+2 = 6overestimates!
E8E→D→G = 4+2=64+2 = 6overestimates
B4B→D→G = 2+2=42+2 = 4fine

One counter-example suffices: h(A)=14>h∗(A)=6h(A) = 14 > h^*(A) = 6 → not admissible → B ✓ — which is precisely why A* came home with 18 instead of 14.

Tricks & Tips

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