Iterative Deepening DFS
The iterative deepening depth-first search is a state space search algorithm, which combines the goodness of BFS and DFS.
- Time complexity: O(b^d), where b is the branching factor and d is the depth of the goal.
- Space complexity: O(d), where d is the depth of the goal.
Pseudocode of IDDFS:
1 | function IDDFS(root) |
Comparison of DFS, BFS and IDDFS (based on time complexity and space complexity):
The following code block shows the main function of IDDFS:
1 | # recursive function of IDDFS, with parameter depth |