0% found this document useful (0 votes)
46 views11 pages

A Star Algorithm v2

A*

Uploaded by

nirmal2404620
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
46 views11 pages

A Star Algorithm v2

A*

Uploaded by

nirmal2404620
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
> * * A* SEARCH ALGORITHM This is informed search technique also called as HEURISTIC search. This algo. Works using heuristic value. A* uses h(n)->Heuristic function & g(n)->Cost to reach the node ‘n’ from ‘start state. Find shortest path though search spaces. Estimated Cost f(n)=g(n)+h(n) A* gives Fast & Optimal result as compared with previous algorithms. Space & Time Complexity of BFS is also O(V +E) where V is vertices and E is edges. Also Written as:-O(b) “d Where, b->Branching factor d->depth A* SEARCH ALGORITHM * 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 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. The algorithm is as follows- A* SEARCH ALGORITHM The algorithm is as follows- Step-o1: = Define a list OPEN. = Initially, OPEN consists solely of a single node, the start node S. Step-o2: 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. = Ifnode nis a goal state, return success and exit. Step-o4: Expand node n. c A* SEARCH ALGORITHM Step-05: = Ifany 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-o6. Step-06; For each successor node, = Apply the evaluation function f to the node. = Ifthe node has not been in either list, add it to OPEN. Step-07: Go back to Step-o2. (“ A* SEARCH ALGORITHM a Example with Solution: Consider the following graph- * 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. a A* SEARCH ALGORITHM a Example with Solution: Solution- Step-o1; We start with node A. Node B and Node F can be reached from node A. A* Algorithm calculates f(B) and f(F). Estimated Cost f(n)=g(n)+h(n) f(B) =6+8=14 f(F)=3+6=9 Since f(F) < f(B), so it decides to go to node F, ->Closed list(F) Path- A — F c A* SEARCH ALGORITHM ‘ Example with Solution: Solution- Step-o2: Node G and Node H can be reached from node F. A* Algorithm calculates f(G) and f(H). f(G) = (3+) +5=9 f(H) = (3+7) + 3 = 13 Since f(G) < f(H), so it decides to go to node G, ->Closed list(G) Path- A> F >G O A* SEARCH ALGORITHM Example with Solution: Solution- Step-03: Node I can be reached from node G. A* Algorithm calculates f(1). f() = (g+1+3) +1=8 It decides to go to node I. ->Closed list(I) Path-A—+F—-G—I \ a A* SEARCH ALGORITHM \ Example with Solution: Solution- Step-o4: 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) = (414345) +3 = 15 i f(H) = (3414342) + 3 =12 £0) = (3+1+3+3) +0 =10 Since f(J) is least, so it decides to go to node J. ->Closed list(J) Shortest Path- A > F + G1 J A* SEARCH ALGORITHM Advantages of BFS: “+A* Algorithm is one of the best path finding algorithms. It is Complete & Optimal Used to solve complex problems. Disadvantages of BFS: “Requires more memory

You might also like