Tree: Height of a Binary Tree

  • + 0 comments

    simple c++ recursive solution

    int height(Node* root) {
           if(root==NULL){return -1;}
           else{
               int left = height(root->left);
               int right = height(root->right);
               return max(left,right)+1;
           }
        }