While writing program to delete a node from BST, I am not able to make a node null.
Don't know what wrong I am doing.
MainClass:
TreeNode rootNode = null;
rootNode = new TreeNode().insert(75);
rootNode.delete(rootNode, 75);
In TreeNode Class, I have the method delete as(just showing the relevant part of the method):
public void delete(TreeNode node, int valueToDelete) {
if(node == null) {//node supplied is null
return;
}
node = null;
}
In the method delete(), I am setting rootNode itself as null, still its not null, when I reach back to my MainClass. Before and after delete, the value 75 remains as it is in the tree whose root node is pointed by rootNode. I don't know why.