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

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

A variant.

Previous pageContentsNext page