The Definitive Guide to A* Search Algorithm
Key Takeaways
- โA* Search Algorithm achieves O(b^d) average-case time complexity.
- โSpace complexity is O(b^d).
- โOptimal when heuristic is admissible (never overestimates)
- โGame pathfinding (NPC movement, navigation meshes)
- โUnderstanding A* Search Algorithm is essential for technical interviews.
What Is A* Search Algorithm?
How A* Search Algorithm Works
Time & Space Complexity Analysis
Did You Get the Big O Right? NexusBro Will Tell You in Seconds.
Paste your algorithm. Get complexity analysis, edge cases, and optimizations.
Test My AlgorithmAdvantages and Disadvantages
Real-World Use Cases
Implementation Tips
Practice Problems
Unlock Unlimited QA Audits for $15.99/mo
Free: 5 audits/day. Pro $15.99/mo: 50/day + 250 pages. Pro Max $99/mo: unlimited audits, 10K pages, API access.
See PlansFrequently Asked Questions
What makes a heuristic admissible?
A heuristic is admissible if it never overestimates the actual cost to reach the goal. For grid pathfinding, Manhattan distance and Euclidean distance are common admissible heuristics. Admissibility guarantees A* finds the optimal path.
How does A* compare to Dijkstra?
A* is essentially Dijkstra with a heuristic that guides search toward the goal. With h(n) = 0, A* becomes Dijkstra. A good heuristic dramatically reduces the number of nodes explored while maintaining optimality.
What is a consistent heuristic?
A heuristic h is consistent (monotone) if h(n) <= cost(n, n') + h(n') for every edge (n, n'). Consistency implies admissibility and ensures each node is expanded at most once, improving efficiency.
Can A* handle negative edge weights?
No, like Dijkstra, A* does not handle negative edge weights correctly. Use Bellman-Ford for graphs with negative weights, though heuristic guidance is not applicable.
What are alternatives to A* for large graphs?
IDA* (iterative deepening A*) uses less memory. Bidirectional A* searches from both start and goal. Jump Point Search optimizes A* for uniform grids. Hierarchical approaches precompute shortcuts for very large graphs.
Related Articles
Unlock Unlimited QA Audits for $15.99/mo
Free: 5 audits/day. Pro $15.99/mo: 50/day + 250 pages. Pro Max $99/mo: unlimited audits, 10K pages, API access.
See PlansNoizz helps you discover and compare the best new products and tools. Try it free โ
Is your site built to last?
Run a free QA audit and get your Site Health Score in seconds.
Check Your Site FreeNo signup required