CSC403: Tree code: While loop going left [4/29] Previous pageContentsNext page

    public int sizeLeft () {
        Node x = root;
        int sz = 0;
        while (true) {
            if (x == null) break;
            x = x.left;
            sz = sz + 1;
        }
        return sz;
    }

A variant.

Previous pageContentsNext page