I'm creating a recursive function for a binary search tree that removes the minimum node, which would be the leftmost node in the tree. I start at the root and traverse down from there. I'm trying to understand why I'm getting an "invalid read of size 8" error. I'm pretty sure the current node I'm at will never be NULL and I created a conditional for if the tree is empty.
void removeMinimumValue()
{
removeMinimumValue(root);
}
void removeMinimumValue(BSTNode *node)
{
if(root==NULL)
exit(1);
else if (node->leftChild==NULL)
delete node;
else
removeMinimumValue(node->leftChild);
}
Aucun commentaire:
Enregistrer un commentaire