I am trying to delete the right most node of a binary tree. I am using a function to find the right most node which is returning me the the right most node of Binary tree correctly and then I am assigning in the null value. But when I am printing the Binary tree the value of right most node is getting printed.Please help me understand why this is happening.
void deleteNode(Node root, int Key)
{
Node rightMost = rightmost(root); // returns the right most node
rightMost = null
}
If I am deleting the link from parent node to the rightmost child then the node is getting deleted but not when I am making the node itself as null. This is confusing because if the node itself is null then it should get deleted.