Uninformed Search Strategies
Uninformed Search Strategies
Uninformed Search Strategies
STRATEGIES
Dr. J. Ujwala Rekha
AGENDA
• Breadth-first search
• Uniform-cost search
• Depth-first search
• Depth-limited search
• Iterative deepening search
• Bidirectional search
Introduction
• Uninformed search is also called as blind search.
• The term means that the strategies have no
additional information about states. All they can do is
generate successors and distinguish a goal state from
a non-goal state.
• All search strategies are distinguished by the order in
which nodes are expanded.
• Strategies that know whether one non-goal state is
“more promising” than another are called informed
search or heuristic search strategies.
BREADTH-FIRST SEARCH
• Breadth-first search is a simple strategy in which the root
node is expanded first, then all the successors of the root
node are expanded next, then their successors, and so on.
• In general, all the nodes are expanded at a given depth in
the search tree before any nodes at the next level are
expanded.
• In other words, shallowest unexpanded node is expanded.
• The graph-search version of BFS is implemented by using a
FIFO queue for the frontier.
• The goal test is applied to each node when it is generated
rather than when it is selected for expansion.
Example of BFS
Example of BFS
Properties of BFS
• Completeness: if the shallowest goal node is at some finite depth d,
BFS will eventually find it after generating all shallower nodes
(provided the branching factor b is finite).
• Optimality: The shallowest goal node is not necessarily the optimal
one.
• Time Complexity: The root of the search tree generates b nodes at the
first level, each of which generates b more nodes, for a total of b2
nodes at the second level. Each of these generates b more nodes,
yielding b3 nodes at the third level, and so on.
– If the solution is at depth d, then the total number of nodes
generated is b+b2+b3+…+bd=O(bd).
• Space Complexity: Every node remains in the memory. There will be
O(bd-1) nodes in the explored set and O(bd) nodes in the frontier, so the
space complexity is O(bd), i.e., it is dominated by the size of the
frontier.
UNIFORM-COST SEARCH
• When all step costs are equal, BFS is optimal.
• Uniform-cost search is an extension of BFS.
• Uniform-cost search expands the least-cost un expanded
node.
• In addition to the ordering of the queue by path cost, there
are two significant differences from BFS.
– The first is that goal test is applied to a node when it is
selected for expansion, rather than when it is first
generated. The reason is that the first goal node that is
generated may be on a suboptimal path.
– The second difference is that a test is added in case a
better path is found to a node currently on the frontier.
Example of Uniform-Cost Search
Example of Uniform-Cost Search
Properties of Uniform-Cost Search
• Optimality: Uniform-cost search is optimal in general
be it expands nodes in order of their optimal path cost.
• Uniform-cost search does not care about the number
of steps a path has, but only about their total cost.
• Completeness: Completeness is guaranteed provided
the cost of every step exceeds some small positive
constant ϵ.
• Uniform-cost search is guided by path costs rather than
depths, so its complexity is not easily characterized in
terms of b and d.
Properties of Uniform-Cost Search
• Let C* be the cost of the optimal solution and assume that
every action costs at least ϵ, then the algorithm’s worst-case
time and space complexity is O(b1+└C*/ϵ˩), which can be much
greater than O(bd).
• Uniform-cost search can explore large trees of small steps before
exploring paths involving large and perhaps useful steps.
• When all step costs are equal, O(b1+└C*/ϵ˩) is O(bd) and uniform-cost
search is similar to BFS, except that the latter stops as soon as it
generates a goal, whereas uniform-cost search examines all the nodes
at the goal’s depth to see if one has a lower cost;
• Uniform-cost search does strictly more work by expanding nodes at
depth d unnecessarily.
DEPTH-FIRST SEARCH
• DFS always expands the deepest node in the current frontier
of the search tree.
• The search proceeds to the deepest level of the search tree. As
the nodes are expanded, they are dropped from the frontier,
so then the search “backs up” to the next deepest node that
still has unexplored successors.
• The graph-search version of DFS uses a LIFO queue. A LIFO
queue means that the most recently generated node is chosen
for expansion.
• The tree-search version of DFS can be implemented using
recursive function that calls itself on each of its children in
turn.
Example of DFS
Example of DFS
Properties of DFS
• The properties of DFS depend strongly on whether the graph-search or
tree-search version is used.
• The graph-search version, which avoids repeated states and redundant
paths, is complete because it will eventually expand every node.
• The tree-search version on the other hand, is not complete. For
example, in Figure 3.6 the algorithm will follow Arad-Sibiu-Arad-Sibiu
loop forever.
• Depth-first tree-search can be modified so that it checks new states
against those on the path from the root to the current node; this avoids
infinite loops but does not avoid the proliferation of redundant paths.
• In infinite spaces, both graph-search and tree-search versions of DFS fail
if an infinite non-goal path is encountered.
Properties of DFS
• Both graph-search and tree-search versions of DFS are non
optimal.
– For example, in Figure 3.16, DFS will explore the entire left sub tree
even if node C is a goal node.
• The time-complexity of depth-firs graph-search is bounded by
the size of the state space (which may be infinite).
• A depth-first tree-search, on the other hand, may generate all
of O(bm) nodes in the search tree, where m is the maximum
depth of any node; this can be much greater than the size of
the state space.
• Note that m itself can be much larger than d (the depth of the
shallowest solution) and is infinite if the tree is unbounded.
Properties of DFS
• With respect to time complexity DFS seems to have no clear
advantage over BFS. But with respect to space complexity DFS
is better than BFS.
• For a graph-search, there is no advantage, but a depth-first
tree search needs to store only a single path from the root to
a leaf node, along with the remaining unexpanded sibling
nodes for each node on the path.
– Once a node has been expanded, it can be removed from
memory as soon as all its descendants have been fully
explored.
• For a state space with branching factor b and maximum depth
m, depth-first search requires a storage of only O(bm) nodes.
Properties of DFS
• A variant of DFS called backtracking search
uses still less memory.
• In backtracking, only one successor is
generated at a time rather than all successors;
each partially expanded node remembers
which successor to generate next.
• In this way, only O(m) memory is needed
rather than O(bm)
DEPTH-LIMITED SEARCH
• The failure of DFS in infinite state spaces can be alleviated
by setting a predetermined depth limit ℓ in DFS.
• Nodes at depth ℓ are treated as if they have no successors.
• However, it is incomplete if we choose ℓ<d, i.e., when the
goal is beyond the depth limit.
• Depth-limited search will also be non optimal if we choose
ℓ>d.
• Time complexity of depth-limited search is O(b ℓ) and the
space complexity is O(bℓ).
• DFS can be viewed as special case of depth-limited search
with ℓ=Ꝏ
ITERATIVE DEEPENING SEARCH
• Iterative deepening search (IDS) is a depth-limited version
of DFS run repeatedly with increasing depth limits until the
goal is found.
• Visits the nodes in the search tree in the same order as
DFS, but the cumulative order in which the nodes are first
visited is effectively breadth-first.
• IDS is optimal like BFS, but uses much less memory.
• IDS combines DFS’ space-efficiency and BFS’ completeness
when the branching factor is finite.
• If a solution exists it will find a solution path with the
fewest arcs.
ITERATIVE DEEPENING SEARCH
• DFS assuming the search
remembers previously-
visited nodes:
A,B,D,F,E,C,G
• DFS without IDS:
remembering previously 0: A
visited nodes: 1: A,B,C,E
A,B,D,F,E,A,B,D,F,E,… 2:A,B,D,F,C,G,E,F
forever caught in the 3:A,B,D,F,E,C,G,E,F,B
A,B,D,F,E cycle
ITERATIVE DEEPENING SEARCH
• Since iterative deepening visits states multiple times, it may
seem wasteful, but it turns out to be not so costly, since in a
tree most of the nodes are in the bottom level, so it does not
matter much if the upper levels are visited multiple times.
• In an iterative deepening search, the nodes at depth d are
expanded once, those at depth d-1 are expanded twice, and
so on up to the root of the search tree, which is expanded d
times. So the total number of nodes generated in the worst
case is
N(IDS)=(d)b+(d-1)b2+…+(1)bd=O(bd) asymptotically same as
BFS
BIDIRECTIONAL SEARCH