- The A* search algorithm considers the estimated cost at each node and goes for the cheapest one.
- This cost
f
is calculated off of two factorsf = g + h
whereg
is the cost so far from the source node andh
is the heuristic cost of the current node from the goal node. - I have used Euclidean distance as a metric for calculating the heuristic distance.
- Priority Queue: This pops off the element with the highest priority first, which in our case would be the node with the cheapest cost.
The time complexity for
get()
andput()
is O(logn).