CSC301: Tree code: Threaded parameter with non-nullable pointer 0 [54/56] Previous pageContentsNext page

    public int size () {
        if (root == null) return 0;
        return size (root, 0);
    }
    private static int size (Node x, int sz) {
        sz = sz + 1;
        if (x.left != null) sz = size (x.left, sz);
        if (x.right != null) sz = size (x.right, sz);
        return sz;
    }

Threaded parameter with non-nullable pointer.

Previous pageContentsNext page