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

AlgorithmFinds optimal path?ConditionWhy
DFS✗—dives into whatever branch is first; ignores costs
BFSonly in unweighted graphs (fewest hops)all edges equallevel-order = fewest edges, not cheapest cost
Dijkstra / UCS✓non-negative edge costsexpands nodes in true-cost order; black means final
Branch & Bound✓lower-bound estimates are valid; loop checking okalways extends the cheapest partial path
A*✓hh admissible (h≤h∗h \leq h^*), finite branching, edge costs ≥ϵ>0\geq \epsilon > 0Lemma-based proof (Week 5): Open always holds a node with f≤C∗f \leq C^*
WA* (w>1w>1)✗ (in general)only if hh never overestimates even after weighting... practically noinflates h → may chase a suboptimal goal before verifying cheaper ones
SMGS (Sparse/Simple Memory Graph Search)✓memory suffices for its bounded duplicate-detectionmemory-bounded variant that keeps optimality where plain SMA*-style forgetting would lose it
Greedy Best-First✗—follows hh blindly, ignores gg entirely
The Exam Answer Pattern

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

w=0w = 0 in Weighted A*

f(n)=g(n)+w⋅h(n)∣w=0=g(n)  ⟹  behaves like Dijkstraf(n) = g(n) + w \cdot h(n)\Big|_{w=0} = g(n) \implies \text{behaves like Dijkstra}

So w = 0 ⇒ optimal (given non-negative costs). And as w→∞w \to \infty, WA* approaches Greedy Best-First — fast but suboptimal. Memorize both endpoints.

h=0h = 0 in A*

Same collapse: f=gf = g ⇒ 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):

  1. Finite branching factor
  2. Edge costs bounded below by some ϵ>0\epsilon > 0 — merely positive isn't enough! Costs like 1,12,14,…1, \frac{1}{2}, \frac{1}{4}, \ldots sum finite while giving infinitely many steps, trapping the search.
  3. h(n)≤h∗(n)h(n) \leq h^*(n) 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
"f=g+Whf = g + Wh, 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
QuizA weighted graph, heuristic properties unknown. Which selections are SAFE for finding an optimal path?
QuizSetting w = 0 in Weighted A* makes the algorithm...
QuizWhy does the A* optimality proof require edge costs ≥ ε > 0 rather than just > 0?