This is my code:
public static int countNodes(BSTNode n) {
if (n==null)
return 0;
else {
int count = 1;
count += countNodes(n.left);
count += countNodes(n.right);
return count;
}
}
It returns a value at the end of 1 more than what the actual count is. I have no idea why.
Help?
Thanks.

New Topic/Question
Reply




MultiQuote








|