This post is completed by 4 users
|
Add to List |
36. Find the Maximum Depth OR Height of a Binary Tree
Objective: Given a binary tree, find the height of it
Example:
Approach: Recursion
- Get the height of the left sub-tree, say left height
- Get the height of the right sub tree, say rightHeight
- Take the Max(leftHeight, rightHeight) and add 1 for the root, and return
- Call recursively.
Time Complexity : O(n)
Height of the Tree is 7