A Star Algorithm
A Star Algorithm
Introduction
• A* Algorithm is one of the best and popular
techniques used for path finding and graph
traversals.
• A lot of games and web-based maps use this
algorithm for finding the shortest path
efficiently.
• It is essentially a best first search algorithm.
Working
• It maintains a tree of paths originating at the
start node.
• It extends those paths one edge at a time.
• It continues until its termination criterion is
satisfied.
• A* Algorithm extends the path that minimizes
the following function-
f(n) = g(n) + h(n)
Working
• A* Algorithm extends the path that minimizes the
following function-
f(n) = g(n) + h(n)
Here,
• ‘n’ is the last node on the path
• g(n) is the cost of the path from start node to
node ‘n’
• h(n) is a heuristic function that estimates cost of
the cheapest path from node ‘n’ to the goal node
8 puzzle problem – A*
• Expand node n.
Algorithm
• Step-05:
• Go back to Step-02.
Problem 2 – path problem
Problem 2 – path problem
• Step-01:
Path- A →
F
Problem 2 – path problem
• Step-02:
• A* Algorithm calculates
f(G) and f(H).
• f(G) = (3+1) + 5 = 9
• f(H) = (3+7) + 3 = 13
• Since f(G) < f(H),
so it decides to go to node G.
Path- A → F →
G
Problem 2 – path problem
• Step-04:
Path- A → F → G → I →
J
Initial node B destination F