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

Greedy vs A* Search Analysis

The document analyzes two search algorithms, Greedy Best-First Search (GBFS) and A* Search, to find the optimal path from a start node S to a goal node G in a search graph. GBFS expanded 6 nodes and found the path S → B → E → D → G, while A* Search expanded only 5 nodes and found the optimal path S → A → D → G. A* guarantees optimal solutions by considering both actual and estimated costs, unlike GBFS which relies solely on heuristic values.
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)
72 views3 pages

Greedy vs A* Search Analysis

The document analyzes two search algorithms, Greedy Best-First Search (GBFS) and A* Search, to find the optimal path from a start node S to a goal node G in a search graph. GBFS expanded 6 nodes and found the path S → B → E → D → G, while A* Search expanded only 5 nodes and found the optimal path S → A → D → G. A* guarantees optimal solutions by considering both actual and estimated costs, unlike GBFS which relies solely on heuristic values.
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

AI Assignment Greedy Best-First

Search & A* Search


In this assignment, we analyze a search graph with heuristic values (h) and edge costs to find the
optimal path from the start node S to the goal node G. We solve it using two algorithms:

Greedy Best-First Search (GBFS

1. Step 1
Open: [S(h=7)]
Closed: [] → Expand S → Add A(h=5), B(h=4) → Pick B (lowest h)
2. Step 2
Open: [A(h=5), B(h=4)]
Closed: [S] → Expand B → Add C(h=5), E(h=2) → Pick E
3. Step 3
Open: [A(h=5), C(h=5), E(h=2)]
Closed: [S, B] → Expand E → Add D(h=2), F(h=1) → Pick F
4. Step 4
Open: [A(h=5), C(h=5), D(h=2), F(h=1)]
Closed: [S, B, E] → Expand F (does not lead to G)
5. Step 5
Open: [A(h=5), C(h=5), D(h=2)]
Closed: [S, B, E, F] → Expand D → Add G(h=0) → Pick G
6. Step 6
Open: [A(h=5), C(h=5), G(h=0)]
Closed: [S, B, E, F, D] → Expand G → Goal Reached!
7. Final Path (reconstructed): S → B → E → D → G
8. Total Nodes Expanded: 6

Greedy Best-First Search - Open/Closed List Table


OPEN CLOSED PATH
[S(h=7)] [] S
[A(h=5), B(h=4)] [S] S→B
[A(h=5), C(h=5), E(h=2)] [S, B] S→B→E
[A(h=5), C(h=5), D(h=2), [S, B, E] S→B→E→F
F(h=1)]
[A(h=5), C(h=5), D(h=2)] [S, B, E, F] S→B→E→D
[A(h=5), C(h=5), G(h=0)] [S, B, E, F, D] S→B→E→D→G
2. A* Search
A* Search is smarter. It looks at both the distance you've already traveled (g) and the estimated
distance left (h). It picks the node with the lowest f(n) = g(n) + h(n).

Step-by-step Execution:

Step 1
Open: [S(f=0+7=7)]
Closed: [] → Expand S → Add A(f=3+5=8), B(f=2+4=6) → Pick B

Step 2
Open: [A(f=8), B(f=6)]
Closed: [S] → Expand B → Add C(f=3+5=8), E(f=6+2=8)

Step 3
Open: [A(f=8), C(f=8), E(f=8)]
Closed: [S, B] → Expand A → Add D(f=6+2=8)

Step 4
Open: [C(f=8), E(f=8), D(f=8)]
Closed: [S, B, A] → Expand D → Add G(f=8+0=8)

Step 5
Open: [C(f=8), E(f=8), G(f=8)]
Closed: [S, B, A, D] → Expand G → Goal Reached!

Final Path (reconstructed): S → A → D → G

Total Nodes Expanded: 5

A* Search - Open/Closed List Table


OPEN CLOSED PATH
[S(f=7)] [] S
[A(f=8), B(f=6)] [S] S→B
[A(f=8), C(f=8), E(f=8)] [S, B] S→B→A
[C(f=8), E(f=8), D(f=8)] [S, B, A] S→A→D
[C(f=8), E(f=8), G(f=8)] [S, B, A, D] S→A→D→G

3. Comparison of Efficiency
Greedy Best-First Search found the path S → B → E → D → G with 6 node expansions.
A* Search correctly found the optimal path S → A → D → G with only 5 node expansions.
A* guarantees the optimal solution using both actual cost (g) and estimated cost (h).
Greedy only looks at heuristic and may miss the best path.
Here, Greedy expanded one more node than A*, and also found a longer-cost path (cost = 11)
compared to A* (cost = 8)

You might also like