0% found this document useful (0 votes)
10 views

3.2 Uninformed Search

Uploaded by

ashish.rawat
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

3.2 Uninformed Search

Uploaded by

ashish.rawat
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 44

Vidya Vikas Education Trust’s

Universal College of Engineering, Vasai(E)

AI
CH:03
Solving Problems by Searching
Content
• Performance evaluation of search strategies,
– Time Complexity,
– Space Complexity,
– Completeness,
– Optimality
Content
• Uninformed Search:
– Depth First Search,
– Breadth First Search,
– Depth Limited Search,
– Iterative Deepening Search,
– Uniform Cost Search,
– Bidirectional Search
Searching for solutions
• We have seen many problems. Now, there is a
need to search for solutions to solve them.
• Understand how searching can be used by the
agent to solve a problem.
• For solving different kinds of problem, an agent
makes use of different strategies to reach the
goal by searching the best possible algorithms.
This process of searching is known as search
strategy.
Measuring problem-solving
performance
Before discussing different search strategies, the
performance measure of an algorithm should be
measured.
Four ways to measure the performance of an
algorithm:
Completeness: It measures if the algorithm
guarantees to find a solution (if any solution
exist).
Measuring problem-solving performance
Optimality: It measures if the strategy searches for an optimal
solution.
Time Complexity: The time taken by the algorithm to find a
solution.
Space Complexity: Amount of memory required to perform a
search.

The complexity of an algorithm depends on branching factor or


maximum number of successors, depth of the shallowest goal node
(i.e., number of steps from root to the path) and the maximum
length of any path in a state space.
Search Techniques
• Uninformed Search Methods:
– Breadth First Search (BFS),
– Depth First Search (DFS),
– Depth Limited Search,
– Depth First Iterative Deepening (DFID),
• Informed Search Methods:
– Greedy best first Search,
– A* Search,
– Memory bounded heuristic Search.
Uninformed Search Algorithms
● Have no additional information on the goal node.
● Uninformed search is also called Blind search.

● The following uninformed search algorithms are discussed in this


section.
○ Breath first search
○ Depth First Search
○ Depth Limited Search
○ Iterative Deepening Depth First Search
○ Uniform Cost Search,
○ Bidirectional Search
Each of these algorithms will have:

•A problem graph, containing the start node S and the goal


node G.
•A strategy, describing the manner in which the graph will be
traversed to get to G .
•A fringe, which is a data structure used to store all the possible
states (nodes) that you can go from the current states.
•A tree, that results while traversing to the goal node.
•A solution plan, which the sequence of nodes from S to G.
1.BFS
https://www.youtube.com/watch?v=QRq6p9s8
NVg
BFS
• Breadth first search is a graph traversal algorithm that starts traversing the
graph from root node and explores all the neighbouring nodes.
• Then, it selects the nearest node and explore all the unexplored nodes.
• The algorithm follows the same process for each of the nearest node until it
finds the goal.
• The algorithm of breadth first search is given below.
• The algorithm starts with examining the node A and all of its neighbours.
• In the next step, the neighbours of the nearest node of A are explored and
process continues in the further steps.
• The algorithm explores all neighbours of all the nodes and ensures that each
node is visited exactly once and no node is visited twice.
BFS
Adv
• It is simple to implement.
• It can be applied to any search problem.
• BFS does not suffer from any potential infinite loop
problem
• BFS will perform well if the search space is small.
Disadv
• If the search space is large then search performance will
be poor compared to other heuristic searches.

• It will perform relatively poor as compare to the depth-


first search algorithm if the goal state lies in the bottom of
the tree.

• BFS needs more memory as compared to DFS.


2. DFS

• The DFS algorithm is a recursive algorithm that uses the


idea of backtracking.
• It involves exhaustive searches of all the nodes by going
ahead, if possible, else by backtracking.
• Finds a path between two vertices by exploring each
possible path as far as possible before backtracking.
https://www.youtube.com/watch?v=w_mdF7LK
KeI
Algo
• DFS visits all vertices in the graph.
• It goes in graph depth to depth so as to
search the goal in more proper way.
• searching starts from selected source and
searches till it last reachable node gets
visited.
• This process continues till remaining
undiscovered nodes are getting visited.
• DFS is based on Stack.
Advantages
• DFS consumes very less space.
• It will reach at goal node in a less time period
than BFS if it traverse in a right path.
Disadvantage
• It is possible that states may keep
reoccurring. there is no guarantee of finding
the goal node.
• sometimes state may enter into infinite loop.
3.Depth Limited Search
• In this algorithm we imposed a boundary or a limit to the depth of the
search domain.
• This limit as the depth limit, making the DFS search strategy more refined
and organized into a finite loop.

• Thus, Depth limited search can be called an extended and refined version of
the DFS algorithm.
• To avoid the infinite loop status while executing the codes, and depth
limited search algorithm is being executed into a finite set of depth called
depth limit.
Algorithm of the example

1. We start with finding and fixing a start node.

2. Then we search along with the depth using the DFS algorithm.

3. Then we keep checking if the current node is the goal node or not.
Advantages of Depth Limited Search

● Depth limited search is better than DFS and requires less time and memory space.

● There are applications of DLS in graph theory particularly similar to the DFS.

● To combat the disadvantages of DFS, we add a limit to the depth, and our search

strategy performs recursively down the search tree.


Disadvantages of Depth Limited Search

● The depth limit is compulsory for this algorithm to execute.

● The goal node will not be found if it does not exist in the desired limit.

● The goal node may not exist in the depth limit set earlier, which will push

the user to iterate further adding execution time.


Iterative Deepening Search(IDS) or Iterative Deepening
Depth First Search(IDDFS)

• There are two common ways to traverse a graph, BFS and DFS.
Considering a Tree (or Graph) of huge height and width, both
BFS and DFS are not very efficient due to following reasons.

• DFS first traverses nodes going through one adjacent of root,


then next adjacent.
• The problem with this approach is, if there is a node close to
root, but not in first few subtrees explored by DFS, then DFS
reaches that node very late.
• Also, DFS may not find shortest path to a node (in terms of
number of edges).
BFS goes level by level, but requires more space.
The space required by DFS is O(d) where d is
depth of tree, but space required by BFS is O(n)
where n is number of nodes in tree
• IDDFS combines depth-first search’s space-
efficiency and breadth-first search’s fast
search (for nodes closer to root).
• IDDFS calls DFS for different depths starting
from an initial value.
• In every call, DFS is restricted from going
beyond given depth.
• So basically we do DFS in a BFS fashion.
Advantages:

● It combines the benefits of BFS and DFS search algorithm in terms of fast search
and memory efficiency.

Disadvantages:

● The main drawback of IDDFS is that it repeats all the work of the previous phase.
Uniform Cost Search
• Uniform-Cost Search is a variant of Dijikstra’s algorithm.
• Here, instead of inserting all vertices into a priority queue, we insert only
source, then one by one insert when needed.
• In every step, we check if the node is already in priority queue (using
visited array).
• used for weighted tree.
• backtracking approach
• gives optimal solution. select the path which has minimum cost.
• Node expansion is based on path cost.
• Uniform-Cost Search is mainly used in Artificial Intelligence.
• In this algorithm from the starting state we will visit the adjacent states
and will choose the least costly state then we will choose the next least
costly state from the all un-visited and adjacent states of the visited
states,
• In this way we will try to reach the goal state (note we wont continue
the path through a goal state ), even if we reach the goal state we will
continue searching for other possible paths( if there are multiple
goals) .
• We will keep a priority queue which will give the least costliest next
state from all the adjacent states of visited states.
Advantages:

● Uniform cost search is optimal because at every state the path with the least cost
is chosen.

Disadvantages:

● It does not care about the number of steps involved in searching and only
concerned about path cost. Due to which this algorithm may be stuck in an
infinite loop.
Bidirectional Search
• Bidirectional search algorithm runs two simultaneous searches, one
form initial state called as forward-search and other from goal node
called as backward-search, to find the goal node.
• Bidirectional search replaces one single search graph with two small
subgraphs in which one starts the search from an initial vertex and
other starts from goal vertex.
• The search stops when these two graphs intersect each other.
• Bidirectional search can use search techniques such as BFS, DFS,
DLS, etc.
Advantages:

● Bidirectional search is fast.


● Bidirectional search requires less memory

Disadvantages:

● Implementation of the bidirectional search tree is difficult.


● In bidirectional search, one should know the goal state in advance.
Thank you !

44

You might also like