CSC301: Tree code: Recursion going left and right [34/56] |
public int size () { return size (root, 0); } private static int size (Node x, int sz) { if (x != null) { sz = size (x.left, sz + 1); sz = size (x.right, sz + 1); } return sz; }
Recursion going left and right. Now computing the size of the tree.
Is this correct?