Chapter 3 Uninformed Search
Chapter 3 Uninformed Search
UnInformed Search
CE –FH2025 – AI
1
Dr. Kalyani Pampattiwar
Uninformed Search Strategies
•Breadth-first search
•Uniform-cost search
•Depth-first search
•Depth-limited search
•Iterative deepening search
Expand nodes using the successor function and check whether state is a goal state or not.
Description
∙ A simple strategy in which the root is expanded first then all the root successors
∙ We visit the search tree level by level that all nodes are expanded at a given depth
4
Dr. Kalyani Pampattiwar
∙ Order in which nodes are expanded.
e.g. Goal state is 11. Assume each cost path is 1. Open is maintained ad as Queue (FIFO)
5
Dr. Kalyani Pampattiwar
∙ Order in which nodes are expanded.
e.g. Goal state is 11. Assume each cost path is 1. Open is maintained ad as Queue (FIFO)
7
Dr. Kalyani Pampattiwar
Closed Open
A
A B, C
B C, D, E
C D, E, F, G
D E, F, G
E F, G, H, I
F G, H, I
G H, I, J, K
H I, J, K, L, N, M
I J, K, L, N, M, O, P
K is goal node.
J K, L, N, M, O, P
Reachable? Yes. Reachable
K L, N, M, O, P, Q
Will you expand successor of K? No
8
Dr. Kalyani Pampattiwar
Advantages:
• BFS will provide a solution if any solution exists.
• If there are more than one solutions for a given problem, then BFS will provide the
minimal solution which requires the least number of steps.
Disadvantages:
• It requires lots of memory since each level of the tree must be saved into memory to
expand the next level.
• BFS needs lots of time if the solution is far away from the root node.
9
Dr. Kalyani Pampattiwar
Performance measure:
Complete: Yes. It always reaches goal ( if b is finite)
Time: 1+b+b2+b3+.....+bd=O(bd) This is the number of nodes we generate
Space: O(bd). Keep every generated node in memory.
Optimal: Yes (if step cost=1)
Conclusion:
Not suitable for searching large graphs. We see that space complexity
is the biggest problem for BFS than its exponential execution time.
10
Dr. Kalyani Pampattiwar
1+10+100
1+10+100+1000+10000
• Nodes=b^d=10^d
• b=10
11
Dr. Kalyani Pampattiwar
2) Depth-first search (DFS)
Description:
∙ DFS progresses by expanding the first child node of the search tree that appears
and thus going deeper and deeper until a goal node Is found, or until it hits a node
that has no children. Then the search backtracks, returning to the most recent node
it hasn’t finished exploring.
∙ Order in which nodes are expanded
e.g. Goal state is 11. Assume each cost path is 1. Open is maintained ad as Stack (LIFO)
Closed: Open
10 : 11, 12
12
Ex
Q is goal node
13
Dr. Kalyani Pampattiwar
Closed Open Closed Open
A I O, P, C
A B, C O P, C
B D, E, C P C
D E, C C F,G
E H, I, C F G
H L, N, M, I, C G J, K
L N, M, I, C J K
N M, I, C K Q
M I, C Q
I O, P, C
Q is goal node
14
Dr. Kalyani Pampattiwar
Performance measure
Advantage:
• DFS requires very less memory as it only needs to store a stack of the nodes on the
• It takes less time to reach to the goal node than BFS algorithm
Disadvantage:
• There is the possibility that many states keep re-occurring, and there is no guarantee
• DFS algorithm goes for deep down searching and sometime it may go to the
infinite loop.
15
Dr. Kalyani Pampattiwar
[Just read]Consider the scenario that there is more than one goal node, and our search
decided to first expand the left sub tree of the root where there is a solution at a very
deep level of this left sub tree, in the same time the right sub tree of the root has a
solution near the root, here comes the non-optimality of DFS that it is not guaranteed that
the first goal to find is the optimal one, so we conclude that DFS is not optimal.
16
Dr. Kalyani Pampattiwar
Performance Measure:
Complete: Not always. Fails in infinite-depth space, spaces with loops
Time: O(bm) terrible if m is much larger than d
Space: O(bm) Linear space.
Optimal: No. It may find non-optimal goal first.
Conclusion:
DFS may suffer from non-termination when the length of a path in the search tree is
17
Dr. Kalyani Pampattiwar
3) Uniform-cost search (UCS)
Description:
∙ Uniform-cost is guided by path cost rather than path length like in BFS, the
algorithms starts by expanding the root, then expanding the node with the
lowest cost from the root, the search continues in this manner for all nodes.
there is no goal state and processing continues until the shortest path to all
18
Dr. Kalyani Pampattiwar
Will discuss
19
Dr. Kalyani Pampattiwar
20
Dr. Kalyani Pampattiwar
Two important points to remember
• If node B already present in Closed. And in Priority Queue if Node B comes again.
We can move Node B to closed if only if is already explored in closed with more
21
Dr. Kalyani Pampattiwar
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 involve in searching and only concerned
about path cost. Due to which this algorithm may be stuck in an infinite loop.
22
Dr. Kalyani Pampattiwar
• If node A comes in Open. And in Priority Queue if Node A is
D10
D10
------- 23
Dr. Kalyani Pampattiwar
• If node B already present in Closed. And in Priority Queue if Node B comes again.
We can move Node B to closed if only if is already explored in closed with more cost.
24
Dr. Kalyani Pampattiwar
25
Dr. Kalyani Pampattiwar
26
Dr. Kalyani Pampattiwar
Performance Measure
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 ε is each step to get closer to the goal node.
Then the number of steps is = C*/ε+1. Here we have taken +1, as we start from state 0 and
end to C*/ε.
Hence, the worst-case time complexity of Uniform-cost search is O(b1 + [C*/ε]).
Space Complexity: The same logic is for space complexity so, the worst-case space
complexity of Uniform-cost search is O(b1 + [C*/ε]).
Optimal: Uniform-cost search is always optimal as it only selects a path with the lowest
Path cost. [Not with –ve cost path]
27
Dr. Kalyani Pampattiwar
4) Depth Limited Search
Depth-limited search can solve the drawback of the infinite path in the Depth-first search.
In this algorithm, the node at the depth limit will treat as it has no successor nodes further.
• Standard failure value: It indicates that problem does not have any solution.
• Cut-off failure value: It defines no solution for the problem within a given depth limit.
28
Dr. Kalyani Pampattiwar
Advantages:
Disadvantages:
• It may not be optimal if the problem has more than one solution.
29
Dr. Kalyani Pampattiwar
Example:
Limit=2
Level 0: S
Level 1: S A B
Level 2: S A C D B I J
Level 3: S A C E F D G B I H J
Completeness: DLS search algorithm is complete if the solution is above the depth-limit.
where b is the branching factor of the search tree, and l is the depth limit.
Optimal: Depth-limited search can be viewed as a special case of DFS, and it is also not
32
Dr. Kalyani Pampattiwar
3) Exercise on Depth Limited Search (DLS)
Goal state G
Limit=3
33
Dr. Kalyani Pampattiwar
5) Iterative deepening depth-first Search (DFID)
Whenever the goal is near the start state, BFS were able to do it quickly. And the drawback
was, it was using up too much of space. So, one nice trade-off between space and time is to
use depth first search to do breadth first search. This is an iterative deepening.
The iterative deepening algorithm is a combination of DFS and BFS algorithms. This search
algorithm finds out the best depth limit and does it by gradually increasing the limit until a
goal is found.
This Search algorithm combines the benefits of Breadth-first search's fast search and depth-
first search's memory efficiency. It is useful when search space is large, and depth of goal
node is unknown.
34
Dr. Kalyani Pampattiwar
Advantages:
• It combines the benefits of BFS and DFS search algorithm in terms of fast
search and memory efficiency.
Disadvantages:
• The main drawback is that that it repeats all the work of the previous phase.
Example:
1'st Iteration-----> A
2'nd Iteration----> A, B, C
3'rd Iteration------>A, B, D, E, C, F, G
In the third iteration, the algorithm will find the goal node.
35
Dr. Kalyani Pampattiwar
Performance Measure:
Completeness:
Time Complexity:
Let's suppose b is the branching factor and depth is d then the worst-case time
complexity is O(bd).
Space Complexity:
Optimal:
IDDFS algorithm is optimal if path cost is a non- decreasing function of the depth of the
node.
36
Dr. Kalyani Pampattiwar
6. Bidirectional Search Algorithm:
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
Bidirectional search can use search techniques such as BFS, DFS, DLS, etc.
37
Dr. Kalyani Pampattiwar
Advantages:
Disadvantages:
38
Dr. Kalyani Pampattiwar
Iteration
First (Level 0) A
Second (Level 1) A, B,C
Third (Level 2) A, B, D, E, C, F, G
Fourth (Level 3) A, B, D, H, I, E, J, K, C, F, G, L, M
Fifth (Level 4) A, B, D, H, I, E, J, X, Y, K, C, F, G, L, M
39
Dr. Kalyani Pampattiwar
40
Dr. Kalyani Pampattiwar
Example:
Optimal: Bidirectional search is Optimal. When you use BFS but not in DFS 41
Dr. Kalyani Pampattiwar
42
Dr. Kalyani Pampattiwar
Iterative deepening
https://www.youtube.com/watch?v=BK8cEWKHCkY
Depth limited search
https://www.youtube.com/watch?v=P7WQUBLKDmo
44
Dr. Kalyani Pampattiwar