Horje
tree height recursion 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));
}
tree height recursion
	public static int height(Node root) {
      	// Write your code here.
        
          if(root == null) 
            return -1;
        
         return 1 + Math.max(height(root.left), height(root.right));
         
    }




Java

Related
functionality of consumer functional interface in java Code Example functionality of consumer functional interface in java Code Example
maven show runtime classpath Code Example maven show runtime classpath Code Example
android studio char to string Code Example android studio char to string Code Example
receive an int from terminal java Code Example receive an int from terminal java Code Example
roblox.com Code Example roblox.com Code Example

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