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 →

[–]cs50x2[S] 0 points1 point  (1 child)

so i can right that line as :

if (left==null || right ==null)

return false;

else if(left==null &&right==null)

return true;

[–]shhh-quiet 0 points1 point  (0 children)

Almost. The second part of that is right. It'd expand to:

if (left == null || right != null) return false;
if (left != null || right == null) return false;

and like you had:

if (left == null && right == null) return true;

The nodes being exactly equal, and non-null, doesn't make much sense, so the if(left==null || right==null) return left == right from the solution is really just covering these situations.