ArticleslgStudy

computer science

Iterative deepening depth-first search

Iterative deepening depth-first search is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Iterative deepening depth-first search rather than just read about it. In short: In computer science, iterative deepening search or more specifically iterative deepening depth-first search (IDS or IDDFS) is a state space/graph search strategy in which a depth-limited version of depth-first search is run repeatedly with increasing depth limits until the goal is found. IDDFS is optimal, meaning that it finds the shallowest goal.

Iterative deepening depth-first search — main illustration
Iterative deepening depth-first search — illustration

Key takeaways

  • Iterative deepening depth-first search belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Iterative deepening depth-first search to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Iterative deepening depth-first search from memory before moving on to harder problems.

Reference excerpt

In computer science, iterative deepening search or more specifically iterative deepening depth-first search (IDS or IDDFS) is a state space/graph search strategy in which a depth-limited version of depth-first search is run repeatedly with increasing depth limits until the goal is found. IDDFS is optimal, meaning that it finds the shallowest goal. Since it visits all the nodes in the search tree down to depth d {\displaystyle d} before visiting any nodes at depth d + 1 {\displaystyle d+1} , the cumulative order in which nodes are first visited is effectively the same as in breadth-first search. However, IDDFS uses much less memory.

Algorithm for directed graphs The following pseudocode shows IDDFS implemented in terms of a recursive depth-limited DFS (called DLS) for directed graphs. This implementation of IDDFS does not account for already-visited nodes.

function IDDFS(root) is for depth from 0 to ∞ do found, remaining ← DLS(root, depth) if found ≠ null then return found else if not remaining then return null

function DLS(node, depth) is if depth = 0 then if node is a goal then return (node, true) else return (null, true) (Not found, but may have children)

else if depth > 0 then any_remaining ← false foreach child of node do found, remaining ← DLS(child, depth−1) if found ≠ null then return (found, true) if remaining then any_remaining ← true (At least one node found at depth, let IDDFS deepen) return (null, any_remaining)

If the goal node is found by DLS, IDDFS will return it without looking deeper. Otherwise, if at least one node exists at that level of depth, the remaining flag will let IDDFS continue. 2-tuples are useful as return value to signal IDDFS to continue deepening or stop, in case tree depth and goal membership are unknown a priori. Another solution could use sentinel values instead to represent not found or remaining level results.

Properties IDDFS achieves breadth-first search's completeness (when the branching factor is finite) using depth-first search's space-efficiency. If a solution exists, it will find a solution path with the fewest arcs. Iterative deepening visits states multiple times, and it may seem wasteful. However, if IDDFS explores a search tree to depth d {\displaystyle d} , most of the total effort is in exploring the states at depth d {\displaystyle d} . Relative to the number of states at depth d {\displaystyle d} , the cost of repeatedly visiting the states above this depth is always small. The main advantage of IDDFS in game tree searching is that the earlier searches tend to improve the commonly used heuristics, such as the killer heuristic and alpha–beta pruning, so that a more accurate estimate of the score of various nodes at the final depth search can occur, and the search completes more quickly since it is done in a better order. For example, alpha–beta pruning is most efficient if it searches the best moves first. A second advantage is the responsiveness of the algorithm. Because early iterations use small values for d {\displaystyle d} , they execute extremely quickly. This allows the algorithm to supply early indications of the result almost immediately, followed by refinements as d {\displaystyle d} increases. When used in an interactive setting, such as in a chess-playing program, this facility allows the program to play at any time with the current best move found in the search it has completed so far. This can be phrased as each depth of the search corecursively producing a better approximation of the solution, though the work done at each step is recursive. This is not possible with a traditional depth-first search, which does not produce intermediate results.

Asymptotic analysis

Time complexity The time complexity of IDDFS in a (well-balanced) tree works out to be the same as breadth-first search, i.e. O ( b d ) {\displaystyle O(b^{d})} , where b {\displaystyle b} is the branching factor and d {\displaystyle d} is the depth of the goal.

Proof In an iterative deepening search, the nodes at depth d {\displaystyle d} are expanded once, those at depth d − 1 {\displaystyle d-1} are expanded twice, and so on up to the root of the search tree, which is expanded d + 1 {\displaystyle d+1} times. So the total number of expansions in an iterative deepening search is

b d + 2 b d − 1 + 3 b d − 2 + ⋯ + ( d − 1 ) b 2 + d b + ( d + 1 ) = ∑ i = 0 d ( d + 1 − i ) b i {\displaystyle b^{d}+2b^{d-1}+3b^{d-2}+\cdots +(d-1)b^{2}+db+(d+1)=\sum _{i=0}^{d}(d+1-i)b^{i}}

… excerpt ends here. Continue reading the full article.

Illustrations

Iterative deepening depth-first search: Bidirectional IDDFS
Bidirectional IDDFS

Worked examples

Example 1 — a first encounter with Iterative deepening depth-first search

Start with the simplest possible case. Write down what Iterative deepening depth-first search claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Iterative deepening depth-first search before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Iterative deepening depth-first search ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Iterative deepening depth-first search

In research
Iterative deepening depth-first search appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Iterative deepening depth-first search in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Iterative deepening depth-first search is common in secondary-school and first-year university syllabi. It links to neighbouring topics Graph algorithms, Search algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for Iterative deepening depth-first search outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Iterative deepening depth-first search” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Iterative deepening depth-first search in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Iterative deepening depth-first search means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Iterative deepening depth-first search out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Iterative deepening depth-first search in simple terms?

In computer science, iterative deepening search or more specifically iterative deepening depth-first search (IDS or IDDFS) is a state space/graph search strategy in which a depth-limited version of depth-first search is run repeatedly with increasing depth limits until the goal is found. IDDFS is o…

Why does Iterative deepening depth-first search matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Iterative deepening depth-first search?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Iterative deepening depth-first search.

Tags

  • Graph algorithms
  • Search algorithms

Keep exploring