in DS edited by
1,652 views
1 vote
1 vote

in DS edited by
1.7k views

2 Comments

in a sight,it looks like AVL tree, i have not solved though!!
0
0
yes it is ,
but can you please give me any trick or pattern how to solve such problems in less time
1
1

1 Answer

2 votes
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!

4 Comments

I marked option D too. They say it's C. I think they framed the wrong options.
0
0
No , i got it Now .
See AVL is height Balanced  BST . But they give size balanced tree.
Both are different . So, option C correct .
0
0
But in option d,  the definition they gave for size balanced tree,  isn't it same as an AVL tree?
0
0

Related questions