Which Algorithms Guarantee the Optimal Path?
The multi-select question that reappears in nearly every paper — one table to answer them all
The Question That Keeps Coming Back
Papers reuse this exact format:
"Given a state space with edge costs, which of the following can find the optimal path? (A) DFS (B) BFS (C) Dijkstra (D) Branch & Bound (E) A* (F) WA* for some w (G) SMGS"
One table answers every variant of this question.
The Master Table
| Algorithm | Finds optimal path? | Condition | Why |
|---|---|---|---|
| DFS | ✗ | — | dives into whatever branch is first; ignores costs |
| BFS | only in unweighted graphs (fewest hops) | all edges equal | level-order = fewest edges, not cheapest cost |
| Dijkstra / UCS | ✓ | non-negative edge costs | expands nodes in true-cost order; black means final |
| Branch & Bound | ✓ | lower-bound estimates are valid; loop checking ok | always extends the cheapest partial path |
| A* | ✓ | admissible (), finite branching, edge costs | Lemma-based proof (Week 5): Open always holds a node with |
| WA* () | ✗ (in general) | only if never overestimates even after weighting... practically no | inflates h → may chase a suboptimal goal before verifying cheaper ones |
| SMGS (Sparse/Simple Memory Graph Search) | ✓ | memory suffices for its bounded duplicate-detection | memory-bounded variant that keeps optimality where plain SMA*-style forgetting would lose it |
| Greedy Best-First | ✗ | — | follows blindly, ignores entirely |
For weighted graphs with unknown heuristic properties: safe picks = Dijkstra, Branch & Bound. BFS only when the question says unweighted. A* only when admissibility is stated. WA* and greedy are traps. This exact combination appeared verbatim in multiple papers.
The Special Cases Exams Love
in Weighted A*
So w = 0 ⇒ optimal (given non-negative costs). And as , WA* approaches Greedy Best-First — fast but suboptimal. Memorize both endpoints.
in A*
Same collapse: ⇒ Dijkstra/Branch-&-Bound behavior, still optimal but explores blindly.
BFS on unweighted graphs
BFS is optimal when cost = number of edges. The trap: papers say "edge costs may or may not be equal" — then BFS loses its guarantee.
DFID
Optimal in unweighted spaces if it doesn't prune via Closed (the new/open-nodes variant); the closed-node-pruning variant can miss shortest paths. See the DFID page.
Decision Flowchart
A*'s Fine Print (when the question adds conditions)
A* is guaranteed optimal iff ALL three hold (Week 5 lecture):
- Finite branching factor
- Edge costs bounded below by some — merely positive isn't enough! Costs like sum finite while giving infinitely many steps, trapping the search.
- everywhere (never overestimates)
If a paper's option list includes A* but the stem says "heuristic properties not known" — you cannot select A*. That phrase exists precisely to eliminate it.
One-Line Summaries to Memorize
| If asked about… | Answer with… |
|---|---|
| "cheapest-first, no heuristic" | Dijkstra — optimal, non-negative costs |
| "extend cheapest partial path" | Branch & Bound — optimal |
| ", large W" | fast, bounded-suboptimal, NOT optimal |
| "memory-bounded but still complete/optimal given room" | SMA*/SMGS family |
| "shortest in hops, infinite tree" | DFID without closed pruning |
| "follows h only" | greedy — never optimal in general |