Probably a dumb question but, How can you tell if a "split" has occurred all the way up a btree? Would it be that the parent pointer would be NULL? Like I said probably a dumb question. I've got my BTreeNode class working (including the add) but the BTree class I have is not resetting the root
void BTree::add (int newKey)
{
if (root == 0)
{
root = new BTreeNode (0, newKey, 0);
}
else // root != 0
{
BTreeNode* current = root;
BTreeNode* newRoot = 0;
while (current -> isNotLeaf())// current node is not a leaf
{
current = current->findChild (newKey);
newRoot = current->addKey (newKey);
}
if (current -> getChild (5) == 0)// split occurred at topmost level (getChild(5) is the parent pointer location
{
root = newRoot;
}
} // end else root != 0
}