SlideShare a Scribd company logo
12
Most read
13
Most read
16
Most read
A* Algorithm
Submitted By: Komal Samdariya
• 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)
• ‘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
Algorithm-
• The implementation of A* Algorithm involves maintaining two lists-
OPEN and CLOSED.
• OPEN contains those nodes that have been evaluated by the heuristic
function but have not been expanded into successors yet.
• CLOSED contains those nodes that have already been visited.
• Step-01:
Define a list OPEN.
Initially, OPEN consists solely of a single node, the start node S.
• Step-02
If the list is empty, return failure and exit.
• Step-03:
Remove node n with the smallest value of f(n) from OPEN and move it to list CLOSED.
If node n is a goal state, return success and exit
• Step-04:
Expand node n.
• Step-05:
If any successor to n is the goal node, return success and the solution by tracing the path from goal node to S.
Otherwise, go to Step-06.
• Step-06
For each successor node,
Apply the evaluation function f to the node.
If the node has not been in either list, add it to OPEN.
• Step-07:
• Go back to Step-02.
Problem-1
• Given an initial state of a 8puzzle problem and final state to be reached-
Initial State Final State
2 8 3
1 6 4
7 5
1 2 3
8 4
7 6 5
• Find the most cost-effective path to reach the final state from initial state using A* Algorithm.
• Consider g(n) = Depth of node and h(n) = Number of misplaced tiles.
g g=0
h=4
f=0+4=4
g=1 g=1 g=1
h=5 h=3 h=5
f=1+5=6 f=1+3=4 f=1+5=6
2 8 3
1 6 4
7 5
2 8 3
1 6 4
7 5
2 8 3
1 4
7 6 5
2 8 3
1 6 4
7 5
2 8 3
1 6 4
7 5
2 8 3
1 6 4
7 5
2 8 3
1 4
7 6 5
2 8 3
1 6 4
7 5
2 3
1 8 4
7 6 5
2 8 3
1 4
7 6 5
2 8 3
1 4
7 6 5
g=2 g=2 g=2
h=3 h=3
h=5
g=3 g=3 g=3 g=3
h=3 h=4 h=2 h=4
8 3
2 1 4
7 6 5
2 8 3
7 1 4
6 5
2 8 3
1 4
7 6 5
2 3
1 8 4
7 6 5
2 3
1 8 4
7 6 5
2 3
1 8 4
7 6 5
1 2 3
8 4
7 6 5
g=4
h=1
g=5
h=0 g=5
h=2
1 2 3
7 8 4
6 5
1 2 3
8 4
7 6 5
Problem-2
• The numbers written on edges
represent the distance between the
nodes.
• The numbers written on nodes
represent the heuristic value.
• Find the most cost-effective path to
reach from start state A to final state
J using A* Algorithm.
• Step-01:
• We start with node A.
• Node B and Node F can be reached from node
A.
• A* Algorithm calculates f(B) and f(F).
• f(B) = 6 + 8 = 14
• f(F) = 3 + 6 = 9
• Since f(F) < f(B), so it decides to go to node F.
• Path- A → F
• Step-02:
• Node G and Node H can be reached from
node F.
• 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
• Step-03:
• Node I can be reached from
node G.
• A* Algorithm calculates f(I).
• f(I) = (3+1+3) + 1 = 8
• It decides to go to node I.
• Path- A → F → G → I
• Step-04:
• Node E, Node H and Node J can be reached from
node I.
• A* Algorithm calculates f(E), f(H) and f(J).
• f(E) = (3+1+3+5) + 3 = 15
• f(H) = (3+1+3+2) + 3 = 12
• f(J) = (3+1+3+3) + 0 = 10
• Since f(J) is least, so it decides to go to node J.
• Path- A → F → G → I → J
• This is the required shortest path from node A to node J.
•
A* algorithm

More Related Content

PDF
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
PPTX
Lecture 14 Heuristic Search-A star algorithm
PPTX
A star algorithms
PDF
AI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdf
PPT
AI Lecture 4 (informed search and exploration)
PPTX
Astar algorithm
PPTX
Lecture 21 problem reduction search ao star search
PPT
Hill climbing
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Lecture 14 Heuristic Search-A star algorithm
A star algorithms
AI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdf
AI Lecture 4 (informed search and exploration)
Astar algorithm
Lecture 21 problem reduction search ao star search
Hill climbing

What's hot (20)

PPTX
A Star Search
PDF
I.BEST FIRST SEARCH IN AI
PPTX
A* Algorithm
PPTX
AI search techniques
PPTX
Uninformed Search technique
PPTX
Problem reduction AND OR GRAPH & AO* algorithm.ppt
PPT
Uniformed tree searching
PPT
Prim's Algorithm on minimum spanning tree
PDF
I. Hill climbing algorithm II. Steepest hill climbing algorithm
PDF
I. Mini-Max Algorithm in AI
PPT
Spanning trees
PPT
Graph coloring problem
PPT
Bellman Ford's Algorithm
PPT
Backtracking
PPTX
Informed and Uninformed search Strategies
PPT
AI Lecture 3 (solving problems by searching)
PPT
Time complexity
PPTX
Hill Climbing Algorithm in Artificial Intelligence
PDF
Greedy algorithm activity selection fractional
PPTX
Artificial Intelligence Searching Techniques
A Star Search
I.BEST FIRST SEARCH IN AI
A* Algorithm
AI search techniques
Uninformed Search technique
Problem reduction AND OR GRAPH & AO* algorithm.ppt
Uniformed tree searching
Prim's Algorithm on minimum spanning tree
I. Hill climbing algorithm II. Steepest hill climbing algorithm
I. Mini-Max Algorithm in AI
Spanning trees
Graph coloring problem
Bellman Ford's Algorithm
Backtracking
Informed and Uninformed search Strategies
AI Lecture 3 (solving problems by searching)
Time complexity
Hill Climbing Algorithm in Artificial Intelligence
Greedy algorithm activity selection fractional
Artificial Intelligence Searching Techniques
Ad

Similar to A* algorithm (20)

PPTX
AI_Session 8 A searching algorithm .pptx
PPTX
A-star Algorithm in artificial intelligence.pptx
PPTX
AI_CSE5005_M2_ASearch.pptx for the algorithm for machine
PDF
A* Search Algorithm
PPTX
A Star Algorithm in Artificial intelligence
PPTX
A star algorithm with Pseudcode AI.pptx
PDF
A* and Min-Max Searching Algorithms in AI , DSA.pdf
PPTX
AI3391 Session 10 A searching algorithm.pptx
PPTX
A star
PPTX
Heuristic Searching Algorithms Artificial Intelligence.pptx
PPTX
Unit 3 Informed Search Strategies.pptx
PPTX
heuristic technique.pptx...............................
PDF
An optimized hybrid approach for path
PDF
AN OPTIMIZED HYBRID APPROACH FOR PATH FINDING
PDF
UNIT 2 - Artificial intelligence merged.pdf
PPTX
informed search.pptx
PPT
What is A-Star (A*) Algorithm in Artificial astar.ppt
PPT
HEURISTIC SEARCH IN ARTIFICIAL INTELLEGENCE
PPTX
A-Star Search(part-B) in artificial intelligence.pptx
PDF
IRJET- Artificial Algorithms Comparative Study
AI_Session 8 A searching algorithm .pptx
A-star Algorithm in artificial intelligence.pptx
AI_CSE5005_M2_ASearch.pptx for the algorithm for machine
A* Search Algorithm
A Star Algorithm in Artificial intelligence
A star algorithm with Pseudcode AI.pptx
A* and Min-Max Searching Algorithms in AI , DSA.pdf
AI3391 Session 10 A searching algorithm.pptx
A star
Heuristic Searching Algorithms Artificial Intelligence.pptx
Unit 3 Informed Search Strategies.pptx
heuristic technique.pptx...............................
An optimized hybrid approach for path
AN OPTIMIZED HYBRID APPROACH FOR PATH FINDING
UNIT 2 - Artificial intelligence merged.pdf
informed search.pptx
What is A-Star (A*) Algorithm in Artificial astar.ppt
HEURISTIC SEARCH IN ARTIFICIAL INTELLEGENCE
A-Star Search(part-B) in artificial intelligence.pptx
IRJET- Artificial Algorithms Comparative Study
Ad

Recently uploaded (20)

PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
composite construction of structures.pdf
PPTX
additive manufacturing of ss316l using mig welding
PPTX
Welding lecture in detail for understanding
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
Well-logging-methods_new................
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPT
Mechanical Engineering MATERIALS Selection
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
Sustainable Sites - Green Building Construction
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
Construction Project Organization Group 2.pptx
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
composite construction of structures.pdf
additive manufacturing of ss316l using mig welding
Welding lecture in detail for understanding
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Well-logging-methods_new................
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Embodied AI: Ushering in the Next Era of Intelligent Systems
Mechanical Engineering MATERIALS Selection
OOP with Java - Java Introduction (Basics)
Sustainable Sites - Green Building Construction
Model Code of Practice - Construction Work - 21102022 .pdf
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Construction Project Organization Group 2.pptx
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS

A* algorithm

  • 1. A* Algorithm Submitted By: Komal Samdariya
  • 2. • 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.
  • 3. 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)
  • 4. • ‘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
  • 5. Algorithm- • The implementation of A* Algorithm involves maintaining two lists- OPEN and CLOSED. • OPEN contains those nodes that have been evaluated by the heuristic function but have not been expanded into successors yet. • CLOSED contains those nodes that have already been visited.
  • 6. • Step-01: Define a list OPEN. Initially, OPEN consists solely of a single node, the start node S. • Step-02 If the list is empty, return failure and exit. • Step-03: Remove node n with the smallest value of f(n) from OPEN and move it to list CLOSED. If node n is a goal state, return success and exit • Step-04: Expand node n.
  • 7. • Step-05: If any successor to n is the goal node, return success and the solution by tracing the path from goal node to S. Otherwise, go to Step-06. • Step-06 For each successor node, Apply the evaluation function f to the node. If the node has not been in either list, add it to OPEN. • Step-07: • Go back to Step-02.
  • 8. Problem-1 • Given an initial state of a 8puzzle problem and final state to be reached- Initial State Final State 2 8 3 1 6 4 7 5 1 2 3 8 4 7 6 5
  • 9. • Find the most cost-effective path to reach the final state from initial state using A* Algorithm. • Consider g(n) = Depth of node and h(n) = Number of misplaced tiles. g g=0 h=4 f=0+4=4 g=1 g=1 g=1 h=5 h=3 h=5 f=1+5=6 f=1+3=4 f=1+5=6 2 8 3 1 6 4 7 5 2 8 3 1 6 4 7 5 2 8 3 1 4 7 6 5 2 8 3 1 6 4 7 5
  • 10. 2 8 3 1 6 4 7 5 2 8 3 1 6 4 7 5 2 8 3 1 4 7 6 5 2 8 3 1 6 4 7 5 2 3 1 8 4 7 6 5 2 8 3 1 4 7 6 5 2 8 3 1 4 7 6 5 g=2 g=2 g=2 h=3 h=3 h=5
  • 11. g=3 g=3 g=3 g=3 h=3 h=4 h=2 h=4 8 3 2 1 4 7 6 5 2 8 3 7 1 4 6 5 2 8 3 1 4 7 6 5 2 3 1 8 4 7 6 5 2 3 1 8 4 7 6 5 2 3 1 8 4 7 6 5 1 2 3 8 4 7 6 5 g=4 h=1 g=5 h=0 g=5 h=2 1 2 3 7 8 4 6 5 1 2 3 8 4 7 6 5
  • 12. Problem-2 • The numbers written on edges represent the distance between the nodes. • The numbers written on nodes represent the heuristic value. • Find the most cost-effective path to reach from start state A to final state J using A* Algorithm.
  • 13. • Step-01: • We start with node A. • Node B and Node F can be reached from node A. • A* Algorithm calculates f(B) and f(F). • f(B) = 6 + 8 = 14 • f(F) = 3 + 6 = 9 • Since f(F) < f(B), so it decides to go to node F. • Path- A → F
  • 14. • Step-02: • Node G and Node H can be reached from node F. • 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
  • 15. • Step-03: • Node I can be reached from node G. • A* Algorithm calculates f(I). • f(I) = (3+1+3) + 1 = 8 • It decides to go to node I. • Path- A → F → G → I
  • 16. • Step-04: • Node E, Node H and Node J can be reached from node I. • A* Algorithm calculates f(E), f(H) and f(J). • f(E) = (3+1+3+5) + 3 = 15 • f(H) = (3+1+3+2) + 3 = 12 • f(J) = (3+1+3+3) + 0 = 10 • Since f(J) is least, so it decides to go to node J. • Path- A → F → G → I → J
  • 17. • This is the required shortest path from node A to node J. •