CSC301: More Size: Student code [6/30] |
public int size () { Node x = root; int result = 1; return size (x, result); } private static int size (Node x, int result) { if (x.left != null) { if (x.right != null) { result = +2; return size (x.left, result) + size (x.right, result); } else { result++; return size (x.left, result); } } else if (x.right != null) { result++; return size (x.right, result); } else return result; }
Is it correct?
Can it be improved?