I followed the same approach. For the replace variable I used a function. I am not getting the correct input. Please help ASAP!
2 children case not coming correctly
while deletion you have replace root node with node which is leftmost of right
NOT lefmost of rightmost
do some changes
first pass root->right
node* replacement = smallestMax(root->right)
and in smallestMax () remove first part
so finally
node* smallestMax(node* root) {
while(root->left != NULL) {
root = root->left;
}
return root;
}
i hope this help
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course
I made the above changes. But the output is still wrong. Please help
you have provide another code link
Please provide correct link of code
correct condition for 1 child is
if(!(root->left&&root->right) ){
your condition
if(root->left||root->right){
will hold true even for 2 childeren
that’s why it is not working for 2 childeren case
i hope this help
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course
Such a silly mistake! Thanks man