• + 0 comments

    Javascript code:

    // Start of function getHeight
    this.getHeight = function(root) {
    
        if (root===null) return -1;
        leftheight=this.getHeight(root.left);
        rightheight=this.getHeight(root.right);
        return Math.max(leftheight,rightheight)+1;
    
    }; // End of function getHeight
    

    Don't understand how the output get 2 with the below input. Any expert can help to shed some light please. Thanks!

    9 20 50 35 44 9 15 62 11 13