Greedy Best-First Search: A Complete Solved Numerical Example

Scenario: Pipeline Robot Routing

The Objective: Find the fastest route to the destination (G) by making navigation decisions based exclusively on the estimated remaining distance, completely ignoring the actual travel costs.

Core Mechanics
  • Only the Finish Line f(n)=h(n)f(n) = h(n): Greedy Search evaluates nodes purely by their estimated distance to the goal h(n)h(n). It completely ignores the actual cost traveled so far.
  • Always Chase the Lowest: At every step, pop the node from the priority queue with the smallest heuristic. The node that looks closest to the goal is always expanded first.
  • Static Scores (No Updates): If you discover a new route to a node already in your Open List, simply ignore it. A node's heuristic h(n)h(n) never changes, so you never update its score.
  • Fast but Foolable (Not Optimal): Because of its severe tunnel vision, a misleading heuristic can trick Greedy into taking a massive detour. It finds the goal quickly, but rarely finds the absolute shortest path.

Step 1: Initial Map Configuration

Find the fastest route to the destination (G) by making navigation decisions based exclusively on the estimated remaining distance, completely ignoring the actual travel costs.

Start Node: S (Heuristic: 10)Goal Node: G (Heuristic: 0)
1
1
1
1
9
2
10
S
7
A
6
C
2
B
4
D
0
G

Step 2: Step-by-Step Resolution Trace

Watch the algorithm evaluate f(n)f(n) scores based solely on the heuristic, aggressively pruning paths even if they might have a lower true cost.

1

Evaluating Node: S

f(S)=h(S)=10f(S) = h(S) = 10
Open List

[ S(10) ]

Closed List

[ ]

Evaluating Neighbors
Evaluated neighbor A (via SA)
h(A)=h(A) = 7
Evaluated neighbor C (via SC)
h(C)=h(C) = 6
2

Evaluating Node: SC

f(C)=h(C)=6f(C) = h(C) = 6
Open List

[ SC(6), SA(7) ]

Closed List

[ S(10) ]

Evaluating Neighbors
Evaluated neighbor D (via SCD)
h(D)=h(D) = 4
3

Evaluating Node: SCD

f(D)=h(D)=4f(D) = h(D) = 4
Open List

[ SCD(4), SA(7) ]

Closed List

[ S(10), SC(6) ]

Evaluating Neighbors
Evaluated neighbor G (via SCDG)
h(G)=h(G) = 0
4

Evaluating Node: SCDG

f(G)=h(G)=0f(G) = h(G) = 0
Open List

[ SCDG(0), SA(7) ]

Closed List

[ S(10), SC(6), SCD(4) ]

Evaluating Neighbors
No valid neighbors to explore (Dead End).
5

Goal Reached: SCDG

Goal Found
Open List

[ SA(7) ]

Closed List

[ S(10), SC(6), SCD(4), SCDG(0) ]

Step 3: Final Computed Path

Final Path Reached

S → C → D → G
Total True Path Cost:4

(Note: Greedy Search does not guarantee this is the optimal shortest path, only that it is the path the algorithm found based purely on heuristics.)

Final Takeaway

Notice how the algorithm completely ignores the true edge weights and only looks at the heuristic (h) values inside the nodes. At Step 1, it chooses C(6) over A(7) simply because 6 is smaller, happily tunneling down S→C→D→G and finding the optimal path by pure luck!