Algorithm
The following pseudocode shows IDDFS implemented in terms of a recursive depth-limited DFS (called DLS).
IDDFS(root, goal) { depth = 0 repeat { result = DLS(root, goal, depth) if (result is a solution) return result depth = depth + 1 } }Depth-limited search can be implemented recursively as follows. Note that it need only check for goal nodes when depth == 0
, because when depth > 0
, DLS is expanding nodes that it has seen in a previous iteration of IDDFS.
Read more about this topic: Iterative Deepening Depth-first Search