You are viewing a single comment's thread. Return to all comments →
If you didn't have the check I think you would end up with a null pointer exception. Something has to stop the recursion.
no since it is void and that we do not need the base case to stop the recursive call. If the root (or current Node) is null it just finish the call and do nothing.
I'm getting confused about what people exactly mean. It would either be
if (root != null)
if (root == null)
I agree that you don't need both of the options, but one is necessary.
This is the correct answer.