Given a binary tree, find if it is height balanced or not. A tree is height balanced if difference between heights of left and right subtrees is not more than one for all nodes of tree. A height balanced tree 1 / \ 10 39 I 5 An unbalanced tree 1 I 10 I 5 Example 1: Input: | 2 1 1 3 Output: 0
Given a binary tree, find if it is height balanced or not. A tree is height balanced if difference between heights of left and right subtrees is not more than one for all nodes of tree. A height balanced tree 1 / \ 10 39 I 5 An unbalanced tree 1 I 10 I 5 Example 1: Input: | 2 1 1 3 Output: 0
Related questions
Question

Transcribed Image Text:Given a binary tree, find if it is height balanced or not.
A tree is height balanced if difference between heights of left
and right subtrees is not more than one for all nodes of tree.
A height balanced tree
1
I
10 39
.
5
An unbalanced tree
1
I
10
I
5
Example 1:
Input:
1
2
1
Output: 0
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 5 steps with 2 images
