Tree: Height of a Binary Tree

  • + 0 comments

    C++11:

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