Horje
find height of a tree Code Example
height of a binary tree
int height(Node* root)
{
    // Base case: empty tree has height 0
    if (root == nullptr)
        return 0;
 
    // recur for left and right subtree and consider maximum depth
    return 1 + max(height(root->left), height(root->right));
}
find height of a tree
// finding height of a binary tree in c++.
int maxDepth(node* node)  
{  
    if (node == NULL)  
        return 0;  
    else
    {  
        /* compute the depth of each subtree */
        int lDepth = maxDepth(node->left);  
        int rDepth = maxDepth(node->right);  
      
        /* use the larger one */
        if (lDepth > rDepth)  
            return(lDepth + 1);  
        else return(rDepth + 1);  
    }  
}  




Cpp

Related
dogecoin price Code Example dogecoin price Code Example
how to grab each character from a string Code Example how to grab each character from a string Code Example
run c++ program mac Code Example run c++ program mac Code Example
c++ simple projects Code Example c++ simple projects Code Example
prime number c++ Code Example prime number c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10