CSC301: Tree code: Returns too quickly! [53/56] Previous pageContentsNext page

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

What's wrong with this code?

Previous pageContentsNext page