Uninformed Search Strategies
Source: Unit 1 §3
Uninformed (blind) search uses only the information in the problem definition. It has no extra knowledge about states: all it can do is generate successors and tell a goal from a non-goal. Every strategy below differs from the others in exactly one way, the order of node expansion.
The five strategies are BFS, UCS, DFS, DLS and IDS.
Breadth-first search
BFS expands the root, then every successor of the root, then all of their successors. All nodes at a given depth are expanded before any node at the next level, which falls straight out of using a FIFO queue for the frontier.
| Criterion | BFS |
|---|---|
| Complete? | Yes, if the shallowest goal is at finite depth d and b is finite. |
| Time | b + b² + b³ + … + bᵈ = O(bᵈ) |
| Space | O(bᵈ) - every generated node stays in memory: O(b^(d-1)) explored plus O(bᵈ) on the frontier. This is the weakness. |
| Optimal? | Only if path cost is a non-decreasing function of depth, most commonly when all step costs are equal. Otherwise the shallowest goal need not be the cheapest. |
The space term is the same as the time term, and memory is the scarcer resource. A branching factor of 10 at depth 10 is ten billion nodes held at once. In practice BFS dies of memory exhaustion while the CPU is still willing.
Uniform-cost search
When step costs are equal, expanding the shallowest node is the same as expanding the cheapest one, and BFS is optimal. UCS is the extension for when costs are not uniform: it expands the node with the lowest path cost , using a priority queue ordered by .
is the total path cost from the start node to node . UCS always expands the smallest on the frontier.
- The goal test happens on pop, not on generation. A goal spotted while generating children may still be reachable more cheaply another way, so UCS refuses to commit until that node is the cheapest thing on the frontier.
- If a cheaper path to a frontier node turns up, the frontier entry is replaced, not added alongside.
- Expand S, which puts
A(5)andB(6)on the frontier, ordered by . - Pop the cheapest, A(5), and expand it. That generates
C(6), since S→A→C costs . - The frontier is now
C(6), B(6), a tie; expand either. - Keep going until a goal node is popped, not merely generated. The answer is the path with the lowest total cost, which need not be the one with the fewest steps.
UCS counts cost, not steps, so an infinite sequence of zero-cost actions is an infinite loop it will happily follow. Completeness is guaranteed only if every step cost exceeds some small positive constant .
Its complexity is quoted in terms of , the cost of the optimal solution, and , rather than and .
| Criterion | UCS |
|---|---|
| Complete? | Yes, if every step cost ≥ ε > 0. |
| Time | O(b^(1 + ⌊C*/ε⌋)) |
| Space | O(b^(1 + ⌊C*/ε⌋)) |
| Optimal? | Yes. Whenever UCS selects a node for expansion, the optimal path to it has already been found. |
Depth-first search
DFS always expands the deepest node on the frontier, using a LIFO stack, which is why it is usually written as a recursive function that calls itself on each child in turn.
| Criterion | DFS |
|---|---|
| Complete? | No. In an infinite-depth space it can follow one branch forever. |
| Time | O(bᵐ) - terrible when m ≫ d, but much faster than BFS when solutions are dense. |
| Space | O(b·m) - linear, and the reason DFS survives at all. |
| Optimal? | No. |
Depth-limited search
DLS fixes the infinite-branch failure by imposing a predetermined depth limit : nodes at depth are treated as if they have no successors.
- solution - a goal was found within the limit.
- failure - there is no solution anywhere in the tree.
- cutoff - the limit was hit, so the answer is "no solution within ℓ", which is not the same thing as failure.
| Criterion | DLS |
|---|---|
| Complete? | No. If the goal is deeper than ℓ, it is never found. |
| Time | O(b^ℓ) |
| Space | O(b·ℓ) |
| Optimal? | No. |
Iterative deepening search
IDS finds the right depth limit by trying every limit: until the goal turns up. It combines DFS's linear memory with BFS's completeness and optimality.
The shallow nodes are regenerated many times, but there are very few of them. The deep nodes, which are almost all of the nodes, are generated once or twice. The overhead is a constant factor, so IDS is still - and that is the answer to "isn't IDS wasteful?"
| Criterion | IDS |
|---|---|
| Complete? | Yes. |
| Time | O(bᵈ) |
| Space | O(b·d) - linear, like DFS. |
| Optimal? | Yes, with uniform step costs. |
Recap
The table below is the one worth reproducing from memory.
| Strategy | Frontier | Complete? | Time | Space | Optimal? |
|---|---|---|---|---|---|
| BFS | FIFO queue | yes (finite b, d) | O(bᵈ) | O(bᵈ) | yes (uniform cost) |
| UCS | priority queue on g | yes (step ≥ ε) | O(b^(1+⌊C*/ε⌋)) | O(b^(1+⌊C*/ε⌋)) | yes |
| DFS | LIFO stack | no | O(bᵐ) | **O(b·m)** | no |
| DLS | stack + limit ℓ | no | O(b^ℓ) | O(b·ℓ) | no |
| IDS | iterated DFS | yes | O(bᵈ) | O(b·d) | yes (uniform cost) |
- States - the locations of the tiles.
- Start state - the given position of the tiles.
- Goal state - the given target configuration.
- Actions - move the blank left, right, up or down.
- Cost - 1 per move.
A maze is the standard DFS problem. Note also what this definition of search deliberately excludes: games against an adversary whose moves you do not control, problems involving chance, continuous state spaces, and distributed or team control problems.