CSC301: More Size: Student code [4/30] |
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?