A* Search
Order frontier cells by path cost plus heuristic and reconstruct an optimal route when the goal is settled.
Core idea
A* orders its priority queue by f equals g plus h: the exact cost already paid plus a heuristic estimate to the goal. Relaxation updates a neighbor when a cheaper g value appears.
Read the visualization
Open cells form the frontier, closed cells are settled, and the active cell has the smallest f score. Once the goal settles, predecessor arrows reveal the route.
Initialize the start with zero path cost and its heuristic estimate to the goal.
Complexity and tradeoffs
Time: Worst O((V+E) log V). Space: O(V). An admissible consistent heuristic preserves optimality and often explores far fewer states than Dijkstra.
Where it fits
A* powers pathfinding and planning when a useful lower-bound heuristic exists. Setting h to zero gives Dijkstra; an overestimating heuristic may trade optimality for speed.