Skip to main content

Advantage of depth limit search

Short answer

Depth-limited search is DFS with a fixed depth limit, so it terminates even in infinite or cyclic spaces and uses only O(b*l) memory. It is complete when the limit is at least the goal depth, though not optimal, and it is the basis of iterative deepening.

What is the advantage of depth limit search? Compare it with other search strategies.

Depth-limited search (DLS)

Depth-limited search is depth-first search with a predetermined depth limit ℓ. Nodes at depth ℓ are treated as if they have no successors.

DLS(node, goal, limit):
  if node is goal: return solution
  if limit == 0:   return cutoff
  for each child of node:
      result = DLS(child, goal, limit-1)
      if result is a solution: return result
  return cutoff (if any child was cut off) else failure

Advantages

  1. Solves the infinite-path problem of DFS: DFS can go down an endless branch (or loop in a cyclic graph) and never return. The depth limit forces it to stop and backtrack, so the search always terminates.
  2. Low memory: like DFS it needs only O(b·ℓ) space, far less than BFS (O(b^d)).
  3. Simple to implement, and works well when the depth of the solution is known or can be estimated (e.g. in a graph with N nodes the shortest path is at most N − 1; for a route problem the diameter of the map is known).
  4. It is the building block of iterative deepening search, which tries ℓ = 0, 1, 2, ... and combines the advantages of BFS and DFS.

Disadvantages: incomplete if ℓ < d (the goal is deeper than the limit); not optimal if ℓ > d; choosing ℓ is difficult.

Comparison with other strategies

(b = branching factor, d = depth of shallowest goal, m = maximum depth, ℓ = depth limit)

StrategyCompleteOptimalTimeSpace
BFSYesYes (equal costs)O(b^d)O(b^d)
Uniform-costYesYesO(b^(1+C*/ε))O(b^(1+C*/ε))
DFSNoNoO(b^m)O(b·m)
Depth-limitedYes if ℓ ≥ dNoO(b^ℓ)O(b·ℓ)
Iterative deepeningYesYes (equal costs)O(b^d)O(b·d)
BidirectionalYesYes (equal costs)O(b^(d/2))O(b^(d/2))

Thus DLS is preferred over BFS when memory is limited and a depth bound is known, and it is safer than plain DFS.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Artificial Intelligence chapter 3 questions →