CSC403: More Size: Student code [3/10] |
public int size () { return size (root); } private static int size (Node x) { if (x == null) return 0; int szl = size (x.left.left) + size (x.left.right) + 1; int szr = size (x.right.left) + size (x.right.right) + 1; return szl + szr + 1; }
Is this correct?
Can it be improved?