CSC403: Tree code: Back to sanity! [15/29] |
public int size () { return size (root, 0); } private static int size (Node x, int sz) { if (x == null) return sz; sz = size (x.left, sz); sz = size (x.right, sz); sz += 1; return sz; }
"Threaded" parameter: correct version, doing the addition postorder.
What are the initial values of sz
as you go around the tree?