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

icon
Related questions
Question
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
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
steps

Step by step

Solved in 5 steps with 2 images

Blurred answer