A* search

lo-fi, ambient, dreamy, relaxed · 4:19

Listen on 93

Lyrics

[Verse 1]
Graph in hand, need to find the shortest way
From start to goal, what algorithm should I play?
Dijkstra's slow, breadth-first takes too long
A-star's the answer when you want to move along
It's got that heuristic, guides the search with style
Admissible function keeps it worth your while
Manhattan distance when you're on a grid
Euclidean space when angles ain't forbid

[Chorus]
A-star searching, f equals g plus h
G is cost from start, h is heuristic's path
Priority queue keeps the best nodes first
Optimal solution, guaranteed to work
F equals g plus h, that's the formula tight
Explore the cheapest, reach your goal tonight

[Verse 2]
Open list holding all the candidates
Closed list tracking where the search has been
Pull the lowest f-score from the queue
Expand its neighbors, see what's coming through
Check each neighbor, calculate the cost
G from start to here, make sure nothing's lost
Add the heuristic, that's your h-value clean
F-score total tells you what it means

[Chorus]
A-star searching, f equals g plus h
G is cost from start, h is heuristic's path
Priority queue keeps the best nodes first
Optimal solution, guaranteed to work
F equals g plus h, that's the formula tight
Explore the cheapest, reach your goal tonight

[Bridge]
Heuristic must be admissible, never overestimate
Consistent property keeps the search rate straight
When you reach the goal node, trace the path back
Parent pointers guide you on the right track

[Verse 3]
Better than greedy, smarter than blind
Best-first with knowledge, optimized by design
Time complexity depends upon your h
Space can blow up if you don't watch carefully
But when you need that shortest path for real
A-star algorithm's got that perfect feel
From GPS routing to game AI moves
This algorithm's got those winning grooves

[Chorus]
A-star searching, f equals g plus h
G is cost from start, h is heuristic's path
Priority queue keeps the best nodes first
Optimal solution, guaranteed to work
F equals g plus h, that's the formula tight
Explore the cheapest, reach your goal tonight

[Outro]
When the maze gets complex and the choices are wide
Let A-star be your algorithmic guide

← Floyd-Warshall algorithm | Topological sort →