A* Search vs. Greedy Best-First Search

Last Updated July 20, 2026

A* and Greedy Best-First Search both use heuristic guidance, but they order the Open List differently. A* uses f(n)=g(n)+h(n)f(n)=g(n)+h(n), while Greedy Best-First Search uses only h(n)h(n) and ignores accumulated path cost when choosing the next node.

  • Use A* Search when path cost matters and the search must return the cheapest route under valid heuristic and graph-search conditions.
  • Use Greedy Best-First Search when reaching a reasonable route quickly matters more than proving it is the cheapest.
A* balances route cost with goal direction; Greedy follows goal direction alone.

Head-to-Head Showdown

Open List Priority

A* Search: Lowest g(n)+h(n)g(n)+h(n)

Greedy Best First Search: Lowest h(n)h(n)

The Implication: A* can prefer a node that appears farther from the goal when reaching it has been inexpensive. Greedy selects the smallest heuristic value even when the path to that node has already accumulated a large cost.

Optimality Guarantee

A* Search: Conditional cheapest path

Greedy Best First Search: No cheapest-path guarantee

The Implication: A* can guarantee the cheapest path when its heuristic and graph-search conditions satisfy the required assumptions. Greedy ignores accumulated path cost when ranking nodes, so a goal that appears nearby may be reached through a more expensive route.

Heuristic Influence

A* Search: Balanced against g(n)g(n)

Greedy Best First Search: Controls node priority

The Implication: A misleading heuristic competes with accumulated path cost inside A*'s priority score, allowing expensive detours to lose priority. In Greedy Best-First Search, that same estimate fully determines which Open List node is selected next.

Selection Criteria

Scenario:Routing an ambulance through streets with varying travel times where the minimum-time route must be guaranteed.

Choose A* Search:A* orders its Open List through g(n)+h(n)g(n)+h(n), so both travel time already spent and estimated time remaining affect the next node. Under the required correctness conditions, it can guarantee the cheapest route; Greedy Best-First Search cannot.

Scenario:Finding a playable route through a large game map within a strict 55 ms budget where a slightly longer path is acceptable.

Choose Greedy Best-First Search:Greedy Best-First Search orders its Open List only by h(n)h(n), allowing an informative heuristic to drive the search directly toward the goal. A* may evaluate additional nodes to protect path quality that this latency-bound case does not require.

Scenario:Navigating a maze where straight-line distance repeatedly points toward blocked corridors and expensive detours.

Choose A* Search:A* combines the misleading heuristic with accumulated path cost, so routes that repeatedly become expensive receive larger f(n)f(n) values in the Open List. Greedy Best-First Search continues prioritizing whichever node appears closest through h(n)h(n) alone.

Side By Side Trace

A directed graph runs from SS to GG through two competing routes: SAGS \rightarrow A \rightarrow G and SBCGS \rightarrow B \rightarrow C \rightarrow G. Edge labels show travel cost, and each node's floating value is h(n)h(n), the estimated remaining cost to GG. A* orders its Open List by f(n)=g(n)+h(n)f(n)=g(n)+h(n), while Greedy Best-First Search orders its Open List only by h(n)h(n); no ties occur.

7
6
2
2
2
6
S
1
A
4
B
2
C
0
G

Step 1: Evaluating the Start Node

A* Search

Evaluates SS with g(S)=0g(S)=0, h(S)=6h(S)=6, and f(S)=6f(S)=6. Generates AA with f(A)=7+1=8f(A)=7+1=8 and BB with f(B)=2+4=6f(B)=2+4=6. The Open List becomes [B(6),A(8)][B(6), A(8)], and SS moves to the Closed List.

Greedy Best First Search

Evaluates SS with h(S)=6h(S)=6. Generates AA with h(A)=1h(A)=1 and BB with h(B)=4h(B)=4. The Open List becomes [A(1),B(4)][A(1), B(4)], while edge costs 77 and 22 do not affect the ordering, and SS moves to the Closed List.

Step 2: Point of Divergence

A* Search

A* selects BB because f(B)=6f(B)=6 is lower than f(A)=8f(A)=8. Evaluating BCB \rightarrow C gives g(C)=2+2=4g(C)=2+2=4, h(C)=2h(C)=2, and f(C)=6f(C)=6. The Open List becomes [C(6),A(8)][C(6), A(8)], and BB enters the Closed List.

Greedy Best First Search

Greedy Best-First Search selects AA because h(A)=1h(A)=1 is lower than h(B)=4h(B)=4, even though reaching AA already costs 77. Evaluating AGA \rightarrow G adds GG with h(G)=0h(G)=0. The Open List becomes [G(0),B(4)][G(0), B(4)], and AA enters the Closed List.

Step 3: Greedy Reaches the Goal

A* Search

A* selects CC because f(C)=6f(C)=6 is lower than f(A)=8f(A)=8. Evaluating CGC \rightarrow G gives g(G)=4+2=6g(G)=4+2=6, h(G)=0h(G)=0, and f(G)=6f(G)=6. The Open List becomes [G(6),A(8)][G(6), A(8)], and CC enters the Closed List.

Greedy Best First Search

Greedy Best-First Search selects GG because h(G)=0h(G)=0 is lower than h(B)=4h(B)=4. The goal is accepted when GG is removed from the Open List, returning SAGS \rightarrow A \rightarrow G. Node BB remains in the Open List and is never evaluated.

Step 4: A* Reaches the Goal

A* Search

A* selects GG because f(G)=6f(G)=6 is lower than f(A)=8f(A)=8. The goal is accepted when GG is removed from the Open List, returning SBCGS \rightarrow B \rightarrow C \rightarrow G. Node AA remains in the Open List and is never evaluated.

Greedy Best First Search

Performs no further work. Greedy Best-First Search already ended after selecting GG from the Open List with the route SAGS \rightarrow A \rightarrow G.

Final Result

A* Search:A* Search returns SBCGS \rightarrow B \rightarrow C \rightarrow G with total cost 66 after evaluating 44 nodes: SS, BB, CC, and GG. Its Open List ordering kept A(8)A(8) behind B(6)B(6), C(6)C(6), and G(6)G(6), so AA never entered the Closed List.

Greedy Best First Search:Greedy Best-First Search returns SAGS \rightarrow A \rightarrow G with total cost 1313 after evaluating 33 nodes: SS, AA, and GG. Its Open List followed the smallest heuristic values, so it performed less work but accepted the more expensive route.

Common Pitfalls & Exam Mistakes

  • Ordering A*'s Open List using only h(n)h(n).

    The Mistake: Students ignore accumulated path cost and order A*'s Open List only by heuristic value, making the trace behave like Greedy Best-First Search.

    Why It's Wrong: A* orders the Open List by f(n)=g(n)+h(n)f(n)=g(n)+h(n), while Greedy Best-First Search orders it by h(n)h(n) alone. Removing g(n)g(n) can change the next node selected and the final route.

  • Assuming Greedy returns A*'s cheapest path.

    The Mistake: Students conclude that both algorithms must return the same cheapest route because they use the same heuristic values.

    Why It's Wrong: A* combines the heuristic with accumulated path cost and can preserve optimality under the required conditions. Greedy ignores accumulated cost when ordering the Open List, so it can return a more expensive route even with an admissible heuristic.

  • Stopping when GG enters the Open List.

    The Mistake: Students accept the goal immediately when it is generated instead of waiting for it to become the next Open List node.

    Why It's Wrong: In the standard goal-on-pop trace, the goal is accepted when it is removed from the Open List for evaluation. Another node may still have a lower f(n)f(n) in A* or lower h(n)h(n) in Greedy Best-First Search.

Comparative Analysis

AttributeA* SearchGreedy Best First Search
Evaluation Functionf(n)=g(n)+h(n)f(n)=g(n)+h(n)f(n)=h(n)f(n)=h(n)
Accumulated CostIncluded through g(n)g(n)Ignored when ranking
OptimalityConditional guaranteeNot guaranteed
CompletenessConditional guaranteeNot guaranteed generally
Heuristic InfluenceBalanced with path costControls node priority
Typical Trade-OffCheapest-path protectionPotentially quicker route

Common Questions & Edge Cases

  • Do A* Search and Greedy Best-First Search rank Open List nodes differently?

    Yes. A* ranks nodes using f(n)=g(n)+h(n)f(n)=g(n)+h(n), combining accumulated path cost with estimated remaining cost. Greedy Best-First Search ranks nodes using h(n)h(n) alone, so the two algorithms can expand different nodes and return different routes.

  • Can A* Search and Greedy Best-First Search return the same path?

    Yes. Both can return the same route when heuristic ordering leads Greedy toward the path that A* also considers cheapest. Their Open List order may still differ because A* uses g(n)+h(n)g(n)+h(n) while Greedy uses only h(n)h(n).

  • Can Greedy Best-First Search evaluate fewer nodes than A* Search?

    Yes. Greedy can follow a short sequence of low-h(n)h(n) nodes while A* also evaluates nodes with competitive g(n)+h(n)g(n)+h(n) scores. This can reduce work on some graphs, but Greedy gives up A*'s conditional cheapest-path guarantee.

  • Does an admissible heuristic make Greedy Best-First Search as reliable as A* Search?

    No. Admissibility constrains the heuristic estimate, but A* also includes accumulated path cost when ranking its Open List. Greedy uses only h(n)h(n), so admissibility alone cannot guarantee the cheapest path that A* can return under the required conditions.

Explore the Algorithms in Action

Open the theory pages or try the interactive solvers for the algorithms compared above.