Iterative Deepening Search (IDS) combines the space efficiency and optimality of Breadth-First Search(BFS) when all step costs are equal. Instead of diving deep immediately like Depth-First Search (DFS), IDS repeatedly runs a Depth-Limited Search (DLS) with increasing depth limit until the goal is found.

  • Completeness: Yes, as BFS
  • Optimality: Yes, as BFS

Depth-Limited Search (DLS)

Depth-Limited Search (DLS) is a modified version of DFS. It stops at a predefined depth instead of exploring indefinitely. IDS runs a DFS up to a certain depth limit to prevent infinite loops in deep graphs.

Pseudocode

IterativeDeepeningSearch(Graph, start, goal):
    1. Set depth = 0
    2. While True:
        a. result = DepthLimitedSearch(Graph, start, goal, depth)
        b. If result is not "cutoff", return result (goal found or failure)
        c. Increase depth and repeat

DepthLimitedSearch(Graph, current, goal, depth_limit):
    1. If current is the goal, return the path
    2. If depth_limit == 0, return "cutoff" (stop exploring deeper)
    3. For each neighbor of current:
        a. result = DepthLimitedSearch(Graph, neighbor, goal, depth_limit - 1)
        b. If result is not "cutoff", return result (goal found or failure)
    4. Return "cutoff" if no solution is found within depth_limit

Example

l=2

l=3

Multiple expansion overhead

IDS repeatedly expands the same nodes in earlier depth-limited search before reaching the goal. This happens because IDS restarts from the root node at every depth limit, leading to redundant computations.

Overhead is small for most problems

Even though IDS expands nodes multiple times, the overhead remains small for most practical problems. This is mainly because of the geometric growth of nodes per level in a tree.

In a tree problem, the majority of nodes are at the deepest level of the tree. The number of nodes grow exponentially with depth. Earlier levels have very few nodes, so their repeated expansion doesn’t contribute much to the total cost.

Consider this example:

  • Branching factor (b) = 10 (each node has 10 children)
  • Depth limit (d) = 5 (goal is found at depth 5)
DepthNodes at this levelTotal Nodes (BFS)Cumulative Nodes Expanded (IDS)
0111
1101112
2100111123
31,0001,1111,234
410,00011,11112,345
5100,000111,111123,456
**Total nodes expanded by [[Graph Breadth-First Search (BFS)BFS]]**

Total nodes expanded by IDS The final sum is about BFS.

Time complexity

As discussed above, the IDS can revisit previous nodes. The total number of node expansions is given by: Using the sum approximation: Which is same as BFS but with a small constant overhead factor.

Space complexity

IDS behaves like DFS in terms of space. DFS only stores the current path (not the entire frontier like BFS). At depth d, the longest path stored in memory is d nodes.


Back to parent page: Problem Solving and Search

AI AI_Algorithm Problem_Solving Uninformed_Search Iterative_Deepening_Search