| | | | | |

Table::RGet

Same logic as Set::RGet - use key for decisions and data to read/write

Node * RGet(Node* nptr, const K& kval, Node*& location)
{
  if (nptr == 0)
  {
    location = NewNode(kval,D());
    return location;
  }

  // insert recursively
  if (pred_(kval,nptr->key_))
  {
    nptr->lchild_ = RGet(nptr->lchild_, kval, location);
  }
  else if (pred_(nptr->key_,kval))
  {
    nptr->rchild_ = RGet(nptr->rchild_, kval, location);
  }
  else
  {
    nptr->SetAlive();
    location = nptr;
  }
  // repair eactly same code as for Set
  ...
  return nptr;

| | Top of Page | 13. Balanced BSTs - 30 of 35