You are on page 1of 2

A* Algorithm

Is a search algorithm that finds the shortest path between an initial and final point/source.
It can be seen as an extension of Dijkstra’s but uses heuristics to achieve better performance in its
searches to find the shortest path to a specific goal, unlike Dijkstra that looks at all possible goals

Initially designed for graph traversal, it useful in pathfinding in maps or weighted graphs with
nodes/points

A* traverses a map/graph by calculating the shortest path using a heuristic function, h(n), which
estimates the cost of the cheapest path from node ,n, to the destination and g(n), which is the
cost of traversing from the start to n

f(n) = g(n) + h(n)

The time complexity of A* depends on the heuristic used and the space complexity is roughly
the same as other graph search algorithms but both usually evaluate to O(bd)

Where b is the branching factor and d the shortest path

The major drawback of A* is it’s space complexity as it stores all generated nodes in
memory, thus leading it to be over-performed in certain circumstances by other algorithms
than can pre process the graph

You might also like