I am trying to figure out how to remove a node from a binary search tree, I understand that it is different for each node whether it is a leaf, has one child or two children. So as of now my function is nothing more than:
bool BinSTree::remove_root(treeNode*& node) {
if(node -> left == NULL && node -> right == NULL) {
}
elseif(node -> left != NULL && node -> right != NULL) {
}
else {
}
}
I am having a very hard time trying to comprehend the logic, for instance I know for all of them I need to be able to find the parent node to the node being deleted, which is where I am left clueless and any help would be much appreciated!