I am trying to dry me wrong please correct me
Delete the leaf node in BST
instead delete operator if we assign root== NULL or assign another address is not going to impact anything Right?? So what approach i should follow?
this is not correct as node is not acturally deleted
this is known as memory leakage
correct way
if(root->left == NULL && root->right == NULL) {
delete root;
return NULL;
}
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.