Tree/Binary tree/Max Depth of a Binary Tree.cpp
// Recursive function to find out max depth of a binary tree
Recursive function to find out max depth of a binary tree
Recursive function to find out max depth of a binary tree
int maxDepth(TreeNode* root) {
        if(root == NULL) return 0;
        int leftDepth = maxDepth(root->left);
        int rightDepth = maxDepth(root->right);
        return max(leftDepth, rightDepth) +1;
}
int maxDepth ( TreeNode * root ) { if ( root == NULL ) return 0 ; int leftDepth = maxDepth ( root -> left ) ; int rightDepth = maxDepth ( root -> right ) ; return max ( leftDepth , rightDepth ) + 1 ; }
Recursive function to find out max depth of a binary tree
Recursive function to find out max depth of a binary tree
// Root being null means tree doesn't exist. // Get the depth of the left and right subtree  // using recursion. // Choose the larger one and add the root to it.