| | | | | |

Binary Tree Iterator Algorithms: Reverse Patterns

rInitialize(bt)
{
  n = bt.root;                       // always enter tree at root
  ...                                // specific to iterator type
  while (n->IsDead()) Decrement();   // skip dead nodes
}

Decrement()
{
  ...                                // specific to iterator type
}

PrevNode()                           // iterator --()
{
  do Decrement();                    // retreat at least once
  while (n->IsDead());
}

| | Top of Page | 14. BST Iterators - 10 of 41