Uninformed Search
Uninformed Search
4 Uninformed search
strategies
3.4 Uninformed search
strategies
■ Uninformed search
– no information about the number of steps
– or the path cost from the current state to the goal
– search the state space blindly
■ Informed search, or heuristic search
– a cleverer strategy that searches toward the goal,
– Strategies that know whether one goal is more promising
than another.
– based on the information from the current state so far
Uninformed search strategies
■ Breadth-first search
■ Uniform cost search
■ Depth-first search
– Depth-limited search
– Iterative deepening search
■ Bidirectional search
Breadth-first search
■ The root node is expanded first (FIFO)
■ All the nodes generated by the root node are then expanded
■ All the nodes are expanded at a given depth in the search
tree before any nodes at the next level are expanded.
•Initialize a node with the initial state.
•Check if the initial state is already the goal state. If so, return the solution.
•Use a FIFO (first-in-first-out) queue (frontier) to store nodes to be
explored.
•Start a loop:
•If the frontier is empty, return failure (no solution found).
•Pop the shallowest node (the first in the queue).
•Add the node’s state to the explored set.
•For each possible action from the current state, generate a child node.
•If the child state hasn't been explored and is not in the frontier,
check if it is the goal state. If it is, return the solution.
•Otherwise, add the child to the frontier to explore further.
Breadth-first search
S
A D
B D A E
C E E B B F
11
D F B F C E A C G
14 17 15 15 13
G C G F
19 19 17
G 25
Breadth-First Strategy
2 3 Fringe= (1)
4 5 6 7
Breadth-First Strategy
2 3 Fringe = (2, 3)
4 5 6 7
Breadth-First Strategy
2 3 Fringe = (3, 4, 5)
4 5 6 7
Breadth-First Strategy
2 3 Fringe = (4, 5, 6, 7)
4 5 6 7
Breadth-first search
(Analysis)
■ Breadth-first search
– Complete – if the shallowest goal node is at some
finite depth d, breadth-first search will eventually find
it after expanding all shallower nodes
– Optimal, if step cost is 1
The disadvantage
– if the branching factor of a node is large,
■ the space complexity and the time complexity are
enormous
Properties of breadth-first search
■ Complete? Yes (if b is finite)
UCS ensures that the first goal node selected for expansion
is the one with the lowest cost.
UCS is complete if the cost of every step c>0c > 0c>0,
meaning no step has a zero cost (to prevent infinite loops,
such as in a "NoOp" action).
If there’s a zero-cost loop (e.g., an action that returns to the
same state), UCS can get stuck. This is why step costs must
be strictly positive.
Uniform-Cost Search
• Like breadth-first search
• Expand node with lowest path cost.
Properties:
Complete (if b and d are finite)
Optimal (if path cost increases with depth)
Cost is O(b c*/e)
Could be worse than breadth first search
Search
Uniform-Cost Search
Uniform-Cost Snapshot
1 Initial
Visited
4 3
Fringe
2 3 Current
7 2 2 4
Visible
Goal
4 5 6 7
Edge Cost 9
2 5 4 4 4 3 6 9
8 9 10 11 12 13 14 15
3 4 7 2 4 8 6 5 4 3 4 2 8 3 9 2
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Fringe: [27(10), 4(11), 25(12), 26(12), 14(13), 24(13), 20(14), 15(16), 21(18)]
+ [22(16), 23(15)]
Uniform Cost Fringe Trace
1. [1(0)]
2. [3(3), 2(4)]
3. [2(4), 6(5), 7(7)]
4. [6(5), 5(6), 7(7), 4(11)]
5. [5(6), 7(7), 13(8), 12(9), 4(11)]
6. [7(7), 13(8), 12(9), 10(10), 11(10), 4(11)]
7. [13(8), 12(9), 10(10), 11(10), 4(11), 14(13), 15(16)]
8. [12(9), 10(10), 11(10), 27(10), 4(11), 26(12), 14(13),
15(16)]
Assumption: New nodes with the same cost as existing nodes are added after the existing node.
1. [10(10), 11(10), 27(10), 4(11), 26(12), 25(12), 14(13), 24(13), 15(16)]
2. [11(10), 27(10), 4(11), 25(12), 26(12), 14(13), 24(13), 20(14), 15(16), 21(18)]
3. [27(10), 4(11), 25(12), 26(12), 14(13), 24(13), 20(14), 23(15), 15(16), 22(16),
21(18)]
4. [4(11), 25(12), 26(12), 14(13), 24(13), 20(14), 23(15), 15(16), 22(16), 21(18)]
5. [25(12), 26(12), 14(13), 24(13),8(13), 20(14), 23(15), 15(16), 22(16), 9(16), 21(18)]
6. [26(12), 14(13), 24(13),8(13), 20(14), 23(15), 15(16), 22(16), 9(16), 21(18)]
7. [14(13), 24(13),8(13), 20(14), 23(15), 15(16), 22(16), 9(16), 21(18)]
8. [24(13),8(13), 20(14), 23(15), 15(16), 22(16), 9(16), 29(16),21(18), 28(21)]
9. Goal reached!
Depth-first search
■ Always expands one of the nodes at the
deepest level of the tree
■ Only when the search hits a dead end
– goes back and expands nodes at shallower
levels
– Dead end leaf nodes but not the goal
■ Backtracking search
– only one successor is generated on
expansion
– rather than all successors
– fewer memory
Depth-first search
■ Expand deepest unexpanded node
■ Implementation:
– fringe = LIFO queue, i.e., put successors at
front
Depth-first search
■ Expand deepest unexpanded node
■ Implementation:
– fringe = LIFO queue, i.e., put successors at
front
Depth-first search
Expand deepest unexpanded node
■ Implementation:
– fringe = LIFO queue, i.e., put successors at
front
Depth-first search
■ Expand deepest unexpanded node
■ Implementation:
– fringe = LIFO queue, i.e., put successors at
front
Depth-first search
■ Expand deepest unexpanded node
■ Implementation:
– fringe = LIFO queue, i.e., put successors at
front
Depth-first search
■ Expand deepest unexpanded node
■ Implementation:
– fringe = LIFO queue, i.e., put successors at
front
Depth-first search
■ Expand deepest unexpanded node
■ Implementation:
– fringe = LIFO queue, i.e., put successors at
front
Depth-first search
■ Expand deepest unexpanded node
■ Implementation:
– fringe = LIFO queue, i.e., put successors at
front
Depth-first search
■ Expand deepest unexpanded node
■ Implementation:
– fringe = LIFO queue, i.e., put successors at
front
Depth-first search
■ Expand deepest unexpanded node
■ Implementation:
– fringe = LIFO queue, i.e., put successors at
front
Depth-first search
■ Expand deepest unexpanded node
■ Implementation:
– fringe = LIFO queue, i.e., put successors at
front
Depth-first search
■ Expand deepest unexpanded node
■ Implementation:
– fringe = LIFO queue, i.e., put successors at
front
Depth-first search
S
A D
B D A E
C E E B B F
11
D F B F C E A C G
14 17 15 15 13
G C G F
19 19 17 G 25
Depth-first search (Analysis)
■ Not complete
– because a path may be infinite or looping
– then the path will never fail and go back try another
option
■ Not optimal
– it doesn't guarantee the best solution
■ It overcomes
– the time and space complexities
Properties of depth-first search
■ Complete? No: fails in infinite-depth spaces, spaces
with loops
■ complete in finite spaces
■ Optimal? No
Depth-Limited search(DLS)
• Like depth-first search but with depth limit L.
Properties:
Incomplete (if L < d)
non optimal (if L > d)
Time complexity is O(bL)
Space complexity is O(bL)
■ Completeness: DLS is incomplete if the depth limit 𝐿L is
less than the actual depth of the solution 𝑑d. This means it
might miss solutions that exist below the limit.
■ Optimality: DLS is non-optimal if the depth limit 𝐿L is
greater than 𝑑d. In such cases, it may find a solution, but it
might not be the most optimal (i.e., shallowest) solution.
no further.
■ Space Complexity: The space complexity is also 𝑂(𝑏𝐿), as
the algorithm only needs to store up to 𝐿 levels of the
search tree in the recursion stack at any time. This makes it
more memory-efficient than traditional DFS in deep trees.
Iterative Deepening Search(IDS)
• A combination of depth and breadth-first search.
• If no solution is found within the current limit, the algorithm
increases 𝑙 by 1 and repeats the search.
•Commonly used in scenarios where the depth of the solution is
unknown, combining the memory efficiency of DFS with the
completeness and optimality of BFS.
•Low Memory Requirements: IDS combines the space efficiency of
DFS with the completeness and optimality of BFS.
Iterative Deepening
Characteristics
■ Completeness:
IDS is complete because it will eventually reach any depth
where the goal resides.
■ Optimality:
It finds the optimal solution when step costs are uniform
(like BFS).
■ Time Complexity:
Similar to BFS: O(b^d)), where b is the branching factor
and d is the depth of the shallowest goal.
■ Space Complexity:
Like DFS: O(bd), where d is the depth of the goal.
■ Problem: Find a path from "Arad" to "Bucharest" in the map
of Romania using IDS.
■ Steps:
■ Set depth limit L=0.Explore depth 0:
– only "Arad" is checked. Goal not found.
■ Increment L to 1:
– Explore nodes: "Arad," its direct successors.Goal not
found.
■ Increment L to 2: Explore nodes: "Arad," successors of
direct successors.
■ Continue until "Bucharest" is reached.
Search
Bidirectional Search
• Run two searches – one from the initial state
and one backward from the goal.
• We stop when the two searches meet.
Motivation:
Time complexity: (b d/2
+b d/2
)<b d