# When should the iterative deepening search and the depth-limited search be used?

When should the iterative deepening search (IDS), also called iterative deepening depth-first search (IDDFS), and the depth-limited search be used?

If your search tree's branching factor is finite but its depth is unbounded, then DFS isn't "complete". What that means is that it may not ever find the goal node even if it exists. You would use these techniques precisely when this situation arises.

To understand this, let's say you're at the node A in the following tree:

     A
/ \
/   \
B     C
/ \   / \
.   . .   .


You choose to explore subtree rooted at B. Now if there are no goal nodes in that subtree, but the goal nodes were in the subtree rooted at C, then we're stuck. Because we will keep searching there because we don't know beforehand that there are no goal nodes there, next node we explore could always be a goal node. But this essentially means that we'll never finish searching the subtree rooted at B in finite time, and never backtrack to explore the subtree rooted at C.

So to overcome this you would want to iterative deepening depth-first search or depth-limited search.

In depth-limited search you set a limit on the depth you'll explore. Let's say you choose $$d$$ as the depth limit because you know that the solution lies within that depth limit.

And let's say the branching factor for your tree is $$b$$. Going back to our example, you have finite elements in the subtree rooted at B (at most $$b^d$$, can you reason why?), so we'll be able to look at all of them and eventually backtrack and start exploring subtree rooted at C, and we'll be able to find our answer.

Now if you don't know the depth $$d$$ which goal nodes lie at, then you'll use iterative deepening DFS, which essentially does depth limited search but keeps increasing the value of $$d$$ on each iteration, so you're guaranteed to find a goal node, if it exists.

In practice you can consider that IDS is a cheap way to implement a breadth-first search (BFS).

When the branching factor is high, both algorithms have similar computational costs O(B^P) (where P is the length of the solution path and B the branching factor) but IDS requires less memory (typically O(P), while BFS uses O(B^P)).
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 5, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.7409482002258301, "perplexity": 809.5132156539433}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2019-43/segments/1570986654086.1/warc/CC-MAIN-20191014173924-20191014201424-00270.warc.gz"}