100% found this document useful (1 vote)
119 views3 pages

A* Algorithm Pathfinding Example

DSA a star shortest path algorithm

Uploaded by

Myat Noe
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
119 views3 pages

A* Algorithm Pathfinding Example

DSA a star shortest path algorithm

Uploaded by

Myat Noe
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

A* Search Algorithm Exercise

Target node First Steps From Start Node


9 5 0 → 1 (and) 0 → 3
5 6
2 1 2 1. 0 → 1 = f(n) = g(n) + h(n)
6

7 4 = 2 + 16 = 18
0
2. 0 → 3 = f(n) = g(n) + h(n)
6 3 10
Start node
= 6 + 10 = 16

Target node
9 5
5 6
2 1 2
6

7 4
0
6 3 10 Second Steps
Start node
0 → 1 → 2 (and) 0 → 3 → 4 (and) 0 → 3 → 2
1. 0 → 1 → 2 = f(n) = g(n) + h(n)
= (2+5) + 6 = 13
2. 0 → 3 → 4 = f(n) = g(n) + h(n)
= (6+10) + 4 = 20
3. 0 → 3 → 2 = f(n) = g(n) + h(n)
= (6+7) + 6 = 19
Target node Third Steps
9 5 0 → 1 → 2 → 5 (and) 0 → 3 → 4 → 5 (and)
5 6
2 1 2 0→3→2→5
6

7 4 1. 0 → 1 → 2 → 5 = f(n) = g(n) + h(n)


0
= (2+5+9) + 0 = 16
6 3 10
Start node
2. 0 → 3 → 4 → 5 = f(n) = g(n) + h(n)
= (6+10+6) + 0 = 22
3. 0 → 3 → 2 → 5 = f(n) = g(n) + h(n)
= (6+7+9) + 0 = 22

Final selected paths to reach Target node : 0 → 1 → 2 → 5 (or) 0 → 3 → 4 → 5 (or) 0 → 3 → 2 → 5


The Shortest Path is 0 → 1 → 2 → 5.

You might also like