Lecture 04.2: A* Search and Extensions
Understanding A* search, admissible heuristics, and advanced variations like Weighted A* and IDA*.
Greedy Best-First Search is fast but not optimal, because it only looks at the estimated distance to the goal () and ignores the cost of the path accumulated so far ().
To achieve optimal search, we want to minimize the overall length of the path. We introduce as the exact cost of the best path found so far from the initial node to node .
A* Search
A Search* combines uniform-cost search (which minimizes path cost ) with greedy best-first search (which minimizes estimated goal distance ). The core intuition is to avoid expanding paths that are already expensive.
The evaluation function for A* is:
- : Exact cost so far to reach node from the initial state.
- : Estimated cost from node to the nearest goal state.
- : Estimated total cost of the cheapest solution path through node to a goal.
Admissible Heuristics
For A* search to guarantee an optimal solution, the heuristic function must be admissible.
Let be the true cost of the optimal path from node to a goal node. A heuristic is admissible if it never overestimates the cost to reach the goal:
An admissible heuristic is always optimistic. Because an admissible heuristic never overestimates the remaining distance, A* will never mistakenly rule out or skip over a path that could lead to an optimal goal state.
Visualizing Step-by-Step A* Expansion
Let's return to finding a route from Arad to Bucharest using with :

Step-by-Step Search Trace
- Start at Arad: , .
- Expand Arad:
- Sibiu:
- Timisoara:
- Zerind:
- Frontier:
[Sibiu (393), Timisoara (447), Zerind (449)]Expand Sibiu ().
- Expand Sibiu:
- Rimnicu Vilcea:
- Fagaras:
- Arad:
- Oradea:
- Frontier:
[Rimnicu Vilcea (413), Fagaras (415), Timisoara (447), Zerind (449), Arad (646), Oradea (671)]Expand Rimnicu Vilcea ().
- Expand Rimnicu Vilcea:
- Pitesti:
- Craiova:
- Sibiu:
- Frontier:
[Fagaras (415), Pitesti (417), Timisoara (447), Zerind (449), Craiova (526), Sibiu (553)]Expand Fagaras ().
- Expand Fagaras:
- Bucharest:
- Frontier:
[Pitesti (417), Timisoara (447), Zerind (449), Bucharest via Fagaras (450), Craiova (526)]A* does not stop yet! Pitesti () has a lower -value than Bucharest via Fagaras (). Expand Pitesti ().
- Expand Pitesti:
- Bucharest:
- Frontier:
[Bucharest via Pitesti (418), Timisoara (447), Zerind (449), Bucharest via Fagaras (450)]Pop Bucharest via Pitesti (). Goal selected from queue!
By evaluating total path cost , A correctly pivots away from the non-optimal route via Fagaras and finds the optimal path:*
Comparison: Greedy Best-First Search vs. A* Search
| Feature | Greedy Best-First Search | A* Search |
|---|---|---|
| Evaluation Function | ||
| Cost Consideration | Ignores accumulated path cost | Balances accumulated path cost and estimated remaining cost |
| Optimal Path (Romania) | (Cost: ) | (Cost: ) |
| Optimality Guarantee | Non-optimal | Guaranteed optimal (if is admissible) |
| Completeness | Complete only with repeated state elimination | Complete |
The Effect of the Heuristic Function
The choice of evaluation function drastically alters search behavior:
- Dijkstra’s Algorithm (Uniform-Cost Search): Expands states in order of (equivalent to A* with ). It explores outward in all directions equally like ripples in water.
- A Search:* Expands states in order of . It directs exploration toward the goal, eliminating unnecessary state expansions.
- Weighted A Search:* Expands states in order of , where . This heavily weights estimated remaining distance, speeding up computation while bounding suboptimality to at most .
Even with a good heuristic, A* must keep all generated nodes in memory ( space complexity) to reconstruct the optimal path and prevent revisit loops, which can lead to memory exhaustion on very large search spaces.
Advanced Extensions of A*
To overcome memory limitations and speed up search, several variations of A* exist:
1. Bidirectional A*
- Idea: Runs two simultaneous A* searches—one forward from the start state and one backward from the goal state—meeting in the middle.
- Use Case: Drastically reduces the search tree depth, provided an effective heuristic exists in both directions.
2. Iterative Deepening A* (IDA*)
- Idea: Combines A* evaluation with iterative deepening depth-first search. Instead of limiting depth, each iteration uses an increasing -cost limit (threshold).
- Use Case: Reduces space complexity from exponential to linear (like DFS) while retaining A*'s optimality.
3. Beam A*
- Idea: Combines A* with beam search by truncating the frontier to a fixed maximum "beam width" . Only the best nodes are retained at each level.
- Use Case: Essential when memory is strictly constrained or when an approximate fast solution is acceptable.
Lecture 04.1: Informed Search and Heuristics
An introduction to informed search strategies, evaluation functions, and Greedy Best-First Search.
Lecture 05: Heuristic Functions and Optimality
A deep dive into heuristic evaluation, admissibility, consistency, dominance, effective branching factor, and generating admissible heuristics from relaxed problems using the 8-puzzle.