Code is not working for right subtrees??
Delete a node in binary search tree
Could you pass on the link to the question? I cannot find it on hackerblocks.
ur code will not work for the node having 2 child
u have to either find max form left /min from right and then replace it will the node making a recursive call
Node* temp=root->right;
while(temp->left!=NULL)
temp=temp->left;
root->data=temp->data;
root->right=Delete(root->right,temp->data);
i have already done it.The code is working fine for two children for left subtrees but not for right subtrees??
u r always replacing the root data with temp data just find a min value in the right sub tree then replace it will root data now all the value upper root data are in BST form but value below root data after swapping r not in bst so make a recursive call again
make a seperate function for this case
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.