Ai Assignment 2 Modi
Ai Assignment 2 Modi
Submitted By:
NAME Registration
Muhammad Rehan FA21 -BCE-002
Artificial Intelligence
Assignment #: 2
Date: 20-oct-2023
Course Instructor: Dr. Imran Shahzad
Question :
j
Find out the shortest path from Oradea to Craiova in the given graphical map using uniform cost
search algorithm? In the response to this question, you should include:
Part a:
Complete details and steps of the algorithm.
Uniform Cost Search:
The Uniform Cost Search (UCS) algorithm is a variant of Dijkstra's algorithm that is used for
finding the lowest-cost path between a given initial node and all other nodes in a weighted graph.
UCS is a systematic search algorithm that explores paths by expanding the nodes with the lowest
cumulative cost from the initial node.
Part b:
Order of steps/actions taken by the algorithm, and what is in the memory at each step/action.
Step 1:
Step 2:
Step 3:
Step 5:
Step 6
Zerind {Arad:146,Sibiu:151}
Arad {Sibiu:151,Sibiu:286,Timisoara:264}
Sibiu {Rimnicu:231,Fagaras:250,Timisoara:264,Sibiu:286}
Rimnicu {Fagaras:250,Sibiu:286,Timisoara:264,Craiova:377,Pitesti:328}
Fagaras(not goal) {Timisoara:264,Sibiu:286,Pitesti:328,Craiova:377,Bucharest:461}expand
Step 8:
Step 10:
Step 12:
Explored List Frontier List
{Oradea,0}
Oradea { Zerind:71,Sibiu:151}
Zerind {Arad:146,Sibiu:151}
Arad {Sibiu:151,Sibiu:286,Timisoara:264}
Sibiu {Rimnicu:231,Fagaras:250,Timisoara:264,Sibiu:286}
Rimnicu {Fagaras:250,Sibiu:286,Timisoara:264,Craiova:377,Pitesti:328}
Fagaras {Timisoara:264,Sibiu:286,Pitesti:328,Craiova:377,Bucharest:461}
Timisoara {Sibiu:286,Lugoj:375, Pitesti:328,Bucharest:461,Craiova:377}
Sibiu {Pitesti:328,Lugoj:375,Craiova:377,Bucharest:461}
Piteshi {Lugoj:375,Bucharest:429, Craiova:377,Bucharest:461}
Lugoj {Craiova:377,Bucharest:429,Bucharest:461,Mehadia:445}
Craiova(Goal) {Bucharest:429,Bucharest:461,Mehadia:445} no expand
Time Complexity:
C*= 377
£=70
So,
T.C = O(b^(1+C*/£)
= O(3^(1+377/70)
= O(1114
Space Complexity:
C*= 377
£=70
So,
S.C = O(b^(1+C*/£)
= O(3^(1+377/70)
= O(1114)
Part d:
Describe whether uniform cost search provide complete solution or not. Give at least one
example to justify your claim.
Answer :
Uniform cost search is considered complete if two conditions are fulfilled:
1. All step costs are non-negative. (Cost > =0)
2. There exists a finite positive limit on the step costs.
When these prerequisites are satisfied, the uniform cost search algorithm is guaranteed to
identify the optimal solution.
In the context of the Romania map, the step costs adhere to non-negative values, and
there exists a finite positive upper bound on them. Consequently, the uniform cost search
method is assured to deliver a comprehensive solution for determining the shortest path
from Oradea to Craiova, ensuring the discovery of the path with the minimum cost.