Lecture 03.3: Advanced Uninformed Search
Exploring Uniform Cost Search, Depth-Limited Search, Iterative Deepening, and Bidirectional Search.
Breadth-First Search (BFS) and Depth-First Search (DFS) are foundational, but they have major flaws. BFS uses too much memory, and DFS can get stuck in infinite loops and isn't optimal. To solve these issues, we look to advanced uninformed search strategies.
1. Uniform Cost Search (UCS)
A breadth-first search finds the shallowest goal state. This is only guaranteed to be the cheapest solution if the path cost is a function of the depth (i.e., every step costs the same). If step costs vary, BFS fails to find the optimal path.
Uniform Cost Search (UCS) remedies this by expanding the lowest-cost node on the fringe, rather than the shallowest node.
Why UCS matters: A Shortest Path Example
Consider finding the shortest route from Start () to Goal ():
- BFS approach: BFS might expand first (cost 1). Seeing as a successor of , it finds the path with a total cost of . It stops, assuming it found the best path because it reached in 2 steps.
- UCS approach: UCS expands the lowest cost node currently available.
- Starts at . Queue: .
- Expands . Finds with cost . Queue: .
- Crucially, UCS does not stop yet! is cheaper than .
- Expands . Finds through with cost . Queue: .
- Expands and returns the optimal path .
2. Depth-Limited Search (DLS)
The biggest problem with DFS is its unbounded nature; it can traverse down an infinite path forever.
Depth-Limited Search (DLS) resolves this by supplying DFS with a pre-determined depth limit . Nodes at depth are treated as if they have no successors.
- Completeness: Solves the infinite-path problem, but introduces incompleteness if (where is the depth of the shallowest goal).
- Optimality: Non-optimal if .
- Time Complexity:
- Space Complexity:
(Note: Standard DFS is simply a special case of DLS where ).
3. Iterative Deepening Search (IDS)
The problem with DLS is deciding on a suitable depth parameter . Iterative Deepening Search (IDS) avoids this by gradually increasing the depth limit—first 0, then 1, then 2, and so on—until a goal is found.
This guarantees finding the goal when the depth limit finally reaches .
How IDS Works
- Iteration 0: Limit=0. Expand . No goal.
- Iteration 1: Limit=1. Expand , , . No goal.
- Iteration 2: Limit=2. Expand , , , , , , . Goal found!
Is IDS Wasteful?
Generating states multiple times seems wasteful. However, in a search tree with a consistent branching factor, the vast majority of nodes are in the bottom level.
- The nodes on the bottom level are generated once.
- The nodes on the next-to-bottom level are generated twice.
- Only the children of the root are generated times.
Properties of IDS:
- Complete? Yes.
- Optimal? Yes (if step cost = 1).
- Time:
- Space: (linear space, just like DFS!).
IDS combines the benefits of DFS (low memory) and BFS (complete and optimal).
4. Bidirectional Search
Bidirectional search operates by simultaneously searching forward from the initial state and backward from the goal state. The searches expand until they meet in the middle.
- Advantage: Can be significantly faster. It reduces the search space because becomes .
- Example: If and , bidirectional search can be up to 50,000 times faster.
- Challenges: The goal state must be known a priori. Memory consumption can be high, as it maintains two search trees.
Summary of Search Algorithms
| Criterion | BFS | Uniform-Cost (UCS) | DFS | Depth-Limited (DLS) | Iterative Deepening (IDS) |
|---|---|---|---|---|---|
| Complete? | Yes | Yes | No | No | Yes |
| Optimal? | Yes | Yes | No | No | Yes |
| Time | |||||
| Space |
Legend: = branching factor, = depth of shallowest solution, = max depth of the search tree, = depth limit, = cost of optimal solution, = minimum step cost.
Lecture 03.2: Uninformed Search (BFS & DFS)
A deep dive into uninformed search strategies, exploring Breadth-First Search and Depth-First Search with Mermaid diagrams.
Lecture 04.1: Informed Search and Heuristics
An introduction to informed search strategies, evaluation functions, and Greedy Best-First Search.