agar aisa node delete krna h jiske 2 chlid h
toh root->right bhi kuch hoga
toh replace->right ko hum root->right m assign krenge toh pehele wala root->right tree toh delete ho gya na ??
toh ye toh galat hua fir
Delete node BST
are you taking about this ?
root->data = replace->data;
after this root->data will be override with replace->data;
so now we have 2 nodes with replace->data
so we remove one from right part of tree by calling
root->right = deletion_BST(root->right, d);
in this way root->data is deleted
root data delete hoga aisa nii bol rha, voh root toh delete krna hi h
m ye bol rha hu ki
jab hum delete krenge
agar replace node ke right pe kuch bhi h voh root ke right m copy hoga kyunki replace node ka right subtree hum return kr rhe if(root->left == NULL && root->right!=NULL) iss condition ke andar aur voh assign hoga root->right m
toh jo root->right m pehle se tha voh toh remove ho jayega
NO
only replace wala node copy hoga root ke data me
jo right me hogo wo adjust ho jayega
we also have consider that case
if(root->left == NULL && root->right != NULL)
{
node *temp = root->right;
delete root;
return temp;
}
mene jladu jaldi yes kr diya
m ye puch rha tha
root data delete hoga aisa nii bol rha, voh root toh delete krna hi h
m ye bol rha hu ki
jab hum delete krenge
agar replace node ke right pe kuch bhi h voh root->right m copy hoga kyunki replace node ka right subtree hum return kr rhe if(root->left == NULL && root->right!=NULL) iss condition ke andar aur voh assign hoga root->right m
toh jo root->right m pehle se tha voh toh remove ho jayega
join this meet
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.
plz give your valuable feedback by clicking above post link