The Expansion Algorithm

Suppose: Then for any search tree vertex u we can define the expansion algorithm as:

Expand(u)
   children = {}
   for each move ∈ moves do
      child = move.doMove(u)
      if child ≠ null and not OccursOnPath(child, u)
         then d[child] = d[u] + 1
              pred[child] = u
              add child to children
   return children
Note that each child's predecessor and depth information are updated by the expansion algorithm, so that responsibility can be removed from the search algorithm.