Hello. I am having some trouble with removing a node from my bst tree. The program simply exits if I try to remove more than one node from the tree, or when I try to remove a node and then display the contents of the tree. All the other tree functions seem to work without problems. I've been going through all the tutorials I've been able to find online, and while it has greatly helped me see/implement better ways to code some of the tree functions, I'm still getting the same problems. Perhaps there is something I have overlooked? Thanks for any suggestions.
Code:
void tree::w_remove(int data)
{
remove(data, root);
}
//============================================
void tree::remove(int data, node * leaf)
{
search(data, leaf);
if(!leaf)
{
return;
}
else
{
deletenode(leaf);
}
}
//=============================================
node * tree::search(int data, node * leaf)
{
while(leaf)
{
if(data == leaf->data)
{
return leaf;
}
else if(data < leaf->data)
{
return search(data, leaf->left);
}
else
{
return search(data, leaf->right);
}
}
return leaf;
}
//==============================================
void tree::deletenode(node * leaf)
{
//starting from scratch
}