Ad

Given a binary tree defined as below, return the height of the tree.

class Node {
    constructor(val) {
        this.data = val;
        this.left = null;
        this.right = null;
    }
}```


Example:(TBD)
function treeHeight(node)
 {
     if (node == null)
         return 0;
     else
     {
         /* compute the height of each subtree */
         var lheight = treeHeight(node.left);
         var rheight = treeHeight(node.right);
 
         /* use the larger one */
         if (lheight > rheight)
         {
             return(lheight + 1);
         }
         else {
           return(rheight + 1);
         }
     }
 }