Overview
Greedy Best-First Search rushes toward the goal by always expanding the node that looks closest according to the heuristic alone. Ignoring the distance already travelled, it ranks candidates purely by the estimated cost h to the goal.
This makes it fast and often finds a route quickly, but because it never weighs the real cost so far, the path it returns can be far from the shortest.
How Greedy Best-First Search works
- Estimate the heuristic distance h from the start node to the goal.
- From a priority queue keyed only on h, expand the node that appears closest to the goal.
- Add its unvisited neighbours to the queue with their own heuristic estimates.
- Repeat until the goal is reached, following parent links to reconstruct the route.
When to use it
- When speed matters more than optimality and a good-enough path is acceptable.
- Large open maps where a strong heuristic points almost straight at the goal.
- Switch to A* whenever the returned path must actually be the shortest.
Complexity analysis
Greedy Best-First Search shares the O((V + E) log V) worst case of heap-based searches, and with a strong heuristic it can be much faster in practice. But it considers only h and ignores the cost g already paid, so it is not optimal — obstacles can lure it into a long detour it never corrects.
Frequently asked questions
How does Greedy Best-First differ from A*?
A* ranks nodes by f = g + h, balancing the real cost so far against the estimate; greedy search uses h only. Dropping g makes greedy faster but sacrifices the shortest-path guarantee.
Is Greedy Best-First Search ever optimal?
Only in special cases — for example an obstacle-free grid where the heuristic exactly matches the true distance. In general it can return a longer path, which is the price of ignoring the cost already travelled.