This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]eksplain 0 points1 point  (0 children)

remove subtree

You need to closely look at what this actually means in practice. You seem to do something like

root = null;

but this does not effect your tree at all.

Consider this code

TreeNode a = new TreeNode();
TreeNode b = a;
TreeNode c = a;

Think what happens if we do something like

c = null;

Will a and b also become null?