AlgoScope

A* Search

AlgorithmadvancedShortest Path

Best-first search ordered by g + h, distance so far plus an admissible estimate of what is left; optimal and far more focused than BFS.

Decision · step 2 of 23Grid Search and A*: A* leans toward the goal
01234501234011!

Expand (0,0), g = 0, f = 9. New neighbours (1,0), (0,1) get g = 1 and f = 9, 9. Frontier: 2.

Open in the player →or start at step 2

What you will see

On a grid, the explored region leans toward the goal instead of growing in a circle; f = g + h shown per cell.

How grid search and a* works →

Cost

BestO(E)
Averagedepends on heuristic
WorstO(E log V)
SpaceO(V)

Worst case equals Dijkstra with a zero heuristic.

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next, try operations in any order.

Screen readers: Vertices announce name, tentative distance and parent; each step announces the relaxation and whether it improved a distance.

Reduced motion: Distance updates change the label with a crossfade instead of radiating from the edge.

Before this

Related