in a sight,it looks like AVL tree, i have not solved though!!

1 vote

2 votes

look in AVL tree, we know that both side have to be balanced, i.e balance factor -1,0,1 ..now in the question look at the line,where it is returning -1 when abs(left-right>1) means balance factor above 1 [-1 of Bf is also 1, coz absolute is taken]

that means it is not AVL..

Note;for this kind of Code snippet,generally the if condition resembels familiar Tree properties!

that means it is not AVL..

Note;for this kind of Code snippet,generally the if condition resembels familiar Tree properties!

0

I just wanted to confirm this -

output or return value should be -1 as they mentioned ,

so we will check if condition only abs(left-right>1) this one bcs this is giving only -1 right ,

and difference should be greater than 1, so its not balanced.

Answer should be option C.

Am i right??

output or return value should be -1 as they mentioned ,

so we will check if condition only abs(left-right>1) this one bcs this is giving only -1 right ,

and difference should be greater than 1, so its not balanced.

Answer should be option C.

Am i right??