Lecture 3 Search Strategies in Artificial Intelligence
Lecture 3 Search Strategies in Artificial Intelligence
Search Strategies
Dr. Fazeel Abid
Artificial Intelligence
AssistantBy Professor
The University of Lahore
What is Search & Search Algorithm?
In Artificial Intelligence, rational agents perform some kind of search algorithm in the
background to achieve their tasks.
“Search is the systematic examination of states to find path from the start/root state to the goal
state”
A search problem consists of :
State Space.
Set of all possible states where you can be.
Start State.
The state from where the search begins.
Goal Test.
A function that looks at the current state returns whether or not it is the goal state.
The Solution to a search problem is a sequence of actions, called plan that transforms the start
state to the goal state.
This plan is achieved through search algorithms.
Search Terminology & Search Strategies
Problem Space
It is the environment in which the search takes place.
Problem Instance
It is Initial state + Goal state.
Problem Space Graph
It represents problem state. States are shown by nodes and
operators are shown by edges.
Space Complexity
The maximum number of nodes that are stored in memory.
Time Complexity
The maximum number of nodes that are created.
Admissibility
A property of an algorithm to always find an optimal solution.
Branching Factor
The number of child nodes in the problem space graph.
Depth
Length of the shortest path from initial state to goal state.
Types of search algorithms
Based on the search problems we can classify the search algorithms into uninformed and informed search.
Informed Search
Uninformed Search
Informed search algorithms use domain knowledge in which problem information is
The uninformed search algorithm does not contain any available which can guide the search. Informed search strategies can find a solution more
domain knowledge such as closeness, the location of goal. efficiently than an uninformed search strategy.
Optimality: BFS is optimal.
Depth-First-Search
• Depth-first search is a recursive algorithm for traversing
a tree or graph data structure. In the below search tree, we have shown the flow of
depth-first search.
• It is called the depth-first search because it starts from the
root node and follows each path to its greatest depth
node before moving to the next path.
• DFS uses a stack (LIFO) data structure for its
implementation.
• The process of the DFS algorithm is similar to the BFS
algorithm.
Advantage
Less memory as it only needs to store a stack of the nodes
Less time to reach to the goal node than BFS algorithm (if
it traverses in the right path).
Disadvantage
Many states keep re-occurring, and there is no guarantee of
finding the solution.
Deep down searching and may go to the infinite loop.
Depth-First-Search
• DFS will follow the order
• Root node--->Left node ----> right node.
Completeness: DFS search algorithm is complete within finite
• Searching from root node S, and traverse A, state space as it will expand every node within a limited search
then B, D and E, after traversing E, will tree.
backtrack the tree as E has no other successor Time Complexity: Time complexity of DFS will be equivalent
and still goal node is not found. After to the node traversed by the algorithm.
backtracking traverse node C and then G,
terminate as it found goal node. Space Complexity: DFS algorithm needs to store only single
path from the root node, hence space complexity of DFS
is O(bd)
Completeness
This algorithm is complete is if the branching
factor is finite.
Time Complexity
Let's suppose b is the branching factor and depth
is d then the worst-case time complexity is O(b d).
Space Complexity
The space complexity of IDDFS will be O(b*d).
Optimal
IDDFS algorithm is optimal.
Bidirectional Search
Completeness
Uniform-cost search is complete, such as if there is a
solution, UCS will find it.
Time Complexity
Let C is Cost of the optimal solution, and e is each step to
get closer to the goal node O(b C/e).
Space Complexity
The same logic is for space complexity so, the space
complexity of Uniform-cost search is O(b C/e).
Optimal
Uniform-cost search is always optimal as it only selects a
path with the lowest path cost.
Assignment # 2 (1.5 marks)