Is_balanced(binary tree)


Is this the correct way to take input?As only a limited portion of code has to be written I am not able to understand how to complete the function as I learnt this by making a class.Also has the data be entered in a different form as I guess that part of the code has already been written??

hello @srshubhi398
in which question u have doubt?
pls mention the problem name

is_balanced(binary tree)
to check whether a tree is balanced or not.

image

first node will always be an integer.

question is of height balanced tree.
only the function isHeightBalancedOptimized needs to be written.
Rest all is written.

image

use first and second to access content of pair.

make same chnages at other places as well.

You mean at the place of left and right I should use first and second?

no,p is a pair
to access it content we use p.first and p.second.

I am sorry but I am not able to understand.

read about pairs from here.

1 Like

Thankyou for the help.I understood.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.