0% found this document useful (0 votes)
3 views3 pages

Spring 2025_CS607_1

The assignment requires the implementation of the A* algorithm to find the shortest path from source node S to goal node G in a given graph. The solution details the steps taken, including the open and closed lists, costs at each step, and the final optimal paths with costs calculated. Two optimal paths are identified, both with a total cost of 9, while a non-optimal path is also provided for comparison.

Uploaded by

boldcoldold
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
0% found this document useful (0 votes)
3 views3 pages

Spring 2025_CS607_1

The assignment requires the implementation of the A* algorithm to find the shortest path from source node S to goal node G in a given graph. The solution details the steps taken, including the open and closed lists, costs at each step, and the final optimal paths with costs calculated. Two optimal paths are identified, both with a total cost of 9, while a non-optimal path is also provided for comparison.

Uploaded by

boldcoldold
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
You are on page 1/ 3

ASSIGNMENT

Course Code: CS607 Student ID: PC250200109


Course Name: Artificial Intelligence Student Name: M. Hassaan Sani
Session: Spring 2025

Question:
You are required to implement the A*(A-star) algorithm to find the shortest
node from a source node S to a goal node G considering the following graph:

You must:
 Show the path taken at each step (No need to make diagram at each step)
 Calculate the total cost ( f(n)=g(n) + h(n) ) at each step where g(n) is actual
cost and h(n) is heuristic cost.
 Show the final optimal path with cost.
Solution:

Step Current Open Closed g(n) f(n) Action


Node List List values values Taken
(with f=g
+h)
1 - S - S: 0 S: 7 Start at S
(f=0+7=7
)
2 S A: (f=8), S A:2, B:5
A:8, B:9 Expand
B: (f=9) S, Add
A,B to
Open List
3 A C: (f=8), S,A C:6, D:9 C:8, Expand
B: (f=9), D:10 A. Add
D: (f=10) C,D to
Open List
4 C G: (f=9), S,A,C G:9 G:9 Expand
B: (f=9), C. Add G
D: (f=10) to Open
List
5 B D: (f=9), S,A,C,B D:8 (via D:9 Expand
G: (f=9) B) B. Update
D’s lower
g(n)
6 D G: (f=9) S,A,C,B,D G:9 (via G:9 Expand
D) D.
Confirm
G’s cost
7 G - All nodes - - Goal
Reached

Explanation of Key Steps:


1. Step 1-2: Start at S. Expand to neighbors A and B. Choose A ( lower f(n)
value)
2. Step 3: Expand A. Add C and D to Open.
3. Step 4: Expand C. Add G to Open.
4. Step 5: Expand B. Update D’s g(n) to 8 (cheaper than previous 9)
5. Step 6: Expand D. Confirm G’s cost remains 9.
6. Step 7: Reach G. Backtrack to find two optimal paths.

Optimal Paths and Costs:

1. Path 1: S to A to C to G
Total Cost: 2(S to A) + 4(A to C) + 3(C to G) = 9
2. Path 2: S to B to D to G
Total Cost: 5(S to B) + 3(B to D) + 1( D to G) = 9

Non- Optimal Path:


S to A to D to G: 2 + 7 + 1 = 10

THE END

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy