CSC403: More Storage: Is this correct? [2/7] |
public int size () { return size (root, 0); } private static int size (Node x, int sz) { if (x == null) return sz; sz = sz + 1; size (x.left, sz); size (x.right, sz); return sz; }
Recall this broken version of size
Mistake here is to think of sz
as shared among
the function calls.