Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

We read on Wikipedia > Iterative deepening depth-first search that

The space complexity of IDDFS is O(bd), where b is the branching factor and d is the depth of shallowest goal.

Wikipedia also gives some decent pseudocode for IDDFS; I pythonified it:

def IDDFS(root, goal):
  depth = 0
  solution = None
  while not solution:
    solution = DLS(root, goal, depth)
    depth = depth + 1
  return solution

def DLS(node, goal, depth):
  print("DLS: node=%d, goal=%d, depth=%d" % (node, goal, depth))
  if depth >= 0:
    if node == goal:
      return node

    for child in expand(node):
      s = DLS(child, goal, depth-1)
      if s:
        return s

  return None

So my question is, how does the space complexity include the branching factor? Does that assume that expand(node) takes up O(b) space? What if expand uses a generator that only takes constant space? In that case, would the space complexity still be a function of the branching factor? Are there situations where it is even possible for expand to be a constant-space generator?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

You're right. Wikipedia is wrong! Does anyone have the book referenced on Wikipedia to find out what they mean (maybe they're talking about an optimization of some sort)?

Check out http://citeseerx.ist.psu.edu/viewdoc/summary?doi= and http://intelligence.worldofcomputing.net/ai-search/depth-first-iterative-deepening.html

share|improve this answer
It feels rather self-serving to accept an answer that says I am right and wikipedia is wrong, but oh well. ;) Thanks for the response to my santiy-check. –  Dan Burton Sep 16 '11 at 0:08
Am I wrong or is iterative deepening (in chess at least) used with a transposition table (cache of positions) so branches times depth is the cache size (space used)? –  Kevin Aug 7 '12 at 3:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.