Uninformed Search Methods
Uninformed Search Methods
METHODS
Prepared by
K Kalpana
Assistant Professor
ECE Department
BEC BAPATLA
Introduction
• Uninformed search methods work in the absence of any information, they
are also referred to as blind search methods.
• These methods can understood by a very simple example.
• If we would like to search a boy named Ram a school, with the number of
classes from 1 to 10 and each class having two divisions then the search
would involve going to each and every class till the student named Ram we
are looking for, is found. Since no information is available, we need to select
certain strategy and expand the nodes (here, the classes) in some
predefined order.
• Breadth first search and depth first search are the two basic approaches of
expanding and visiting nodes in the absence of any heuristic.
Types of Uninformed search methods
• Breadth First Search (BFS)
• Uniform Cost Search
• Depth First Search (DFS)
• Depth Limited Search (DLS)
• Iterative Deepening Search (IDS)
• Bi-directional Search
Breadth First Search (BFS)
• The search technique in BFS follows the shallow node approach.
• Here, the basic idea is that across the level of the tree, all the nodes are
searched. So, it is a search technique where from the root node, all the
successors are searched across the level and expanded .
• Queue data structure is used to carry out the search, where things happen
on first in first out basis (FIFO). BFS approach is shown in Figure 3.3
• Here, the dotted arrows indicate the search method. With reference
to the diagram, the search proceeds with the processing of all the
nodes at a particular level and then proceeds to the next one.
Let us take an example of BFS for better understanding. Consider that A is the start state and D is the goal state. With the help of a queue, the example is demonstrated.
In BFS, the step-wise working is as follows:
•:
• Queue Check
A ----
Removed A, is it goal? No, add children. So, B and E are added.
BE
E Removed B, is it goal? No, add children.
So, C is added at the end of queue.
EC
C Removed E, is it goal? No, add children.
So, F and G are added.
CFG
FG Removed C, is it goal? No, add children.
So, D is added.
FGD
GD Removed F, is it goal? No, add children.
Cannot be added, leaf node, so remove the next node.
D Removed G, is it goal? No, add children.
Cannot be added, leaf node, so remove the next node.
Empty Removed D, is it goal? YES!
From the example discussed here, it is clear that each time you add a node, its children are
to be added at the end of the queue as it proceeds level-wise. Since in the example, the
goal state lies at the last level, each and every node or state is traversed and added to the
queue.
The breadth first search algorithm is summarised as follows:
1. Create a node-list (queue) that initially contains the first node.
2. Do till a goal state is found
Remove X from node-list.
If node-list is empty, then exit. Check if this is goal state.
If yes, return the state.
If not, get the next level nodes, i.e., nodes reachable from the parent and add to node-list.
• lf for a given problem, there exists a solution, then BFS is guaranteed to find it out.
• Hence, we can say that it has the completeness property.
• It also possesses the proper of optimality for the shortest path.
• Here, the cost of every edge is same, i.e., the cost to reach from one node to another is
same.
• What about the space and time complexities?
• Let us assume that b is a branching factor or rather the number of successors at every
level and d is the depth.
• Then, the time complexity will be O(bd)-exponential in the depth of the solution.
• Let us map it mathematically. We start from the root and proceed towards the next
level, then the nodes generated at each level are as follows: out. b+b 2+b3+……….+bd+
(bd+1-b)
• This equals to O(bd +1)and hence, it comes to O(bd) and the space complexity is O(bd) as
every node is saved in the memory.
• Hence, this search is not feasible when you have a large search space.
Uniform Cost Search
• Generally, in the search method, with every edge that we traverse, there is a
cost associated with it.
• With BFS, we are assuming that every edge is having the same cost. But in
uniform cost search, all the edges do not have the same cost. So, the
expansion takes place in the order of costs of the edges from the root rather
than the order of the depth.
• At every step, the next thing to be performed expands/selects a node X,
whose cost c(X) is lowest, where c(X) is the sum of cost of edges from root to
the node. It is the core step that is followed while performing the uniform
cost search.
• This search technique can be easily implemented using a priority queue.
• The search is said to ensure completeness if the cost at every edge is
greater or equal to some constant. It, therefore, satisfies the optimal
property as well. The uniform search has O(bd)- space and time
complexities, as it mostly explores large trees.
• The uniform cost search is to be applied from the start, i.e., node A to
the goal node G. We will use a frontier and an expanded list while
generating the solution.
Depth First Search (DFS)
• Taking the example of finding a route to the hotel, you start with one
route and continue it till you come to know that you are at the hotel
or you have to change the path as it will not lead you to the hotel or it
is a dead end.
• While doing so you can think of going back at some point and taking
up some other lane/road that can lead you to the place and this is
very much possible. This is called backtracking.
• It is the stack data structure that is most commonly used in the
implementation of DFS, where the states or the nodes are in
operation on first in last out basis.
DFS tree
Example: Initial state:A Goal state:D
• In search, the same can be formulated as follows:
1. If initial state is the final state (You are just in front of the hotel) -> success,
exit
2. Do it till you get success or failure.
Generate a successor, if no more successors can be generated > failure Go to
step 1 with initial state to be the current generated successor. The algorithm
just discussed above does a DFS. Figure 3.6 depicts the DFS process As
described, the search starts with the initial node or state say root. It proceeds
with its successor and follows the path ahead till either is knows that it has
come to a solution or has to go back and seek new solution as shown in the
figure.
• Stack
Step 1: A<---top Pop A, is it goal? No, push its children on the stack.
B<---top E A's successor is pushed.
Step 2 : B<----top E Pop B, is it goal? No, push its children on the stack.
C<----top E B's successor is pushed.
Step 3: C<----top Pop C, is it goal? No, push its children on the stack.
D<------top E C's successor is pushed.
Step 4: D<------top E Pop D, is it goal?? YES!
Pop all the contents. Path found!
So, by traversing from one path in one direction of depth, we lead to the goal state. In this
case, no backtracking is required.
• Consider the second case, where we want to reach to F.
• The initial working is same as the way we had to reach to D.
• The example below shows that after having reached till D state, the
next step needs backtracking and hence it starts with E. So, we will
start from that point.
• Thus, the stack contents are as follows:
Conclusion for DFS
• With respect to the completeness of DFS, we cannot say that it will
converge.
• The search is not optimal.
Always remember never use DFS if you suspect a big tree depth.
In the worst case, DFS visits all the nodes before getting a solution.
The time complexity will be O(bd)
Space complexity will be O(bd)
Depth Limited Search (DLS)