search
Log In
1 vote
1.1k views

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

1 Answer

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!
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??
0
As far as i am concerend!!

How was the CBT 1?   i mean difficulty?
0
Not up to the GATE Level .
0
can you explain difference between option c and d
0
i a myself confused!! i
0
Why not D ?
0
I marked option D too. They say it's C. I think they framed the wrong options.
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
But in option d,  the definition they gave for size balanced tree,  isn't it same as an AVL tree?

Related questions

0 votes
0 answers
1
175 views
True / False:- 1. : The difference between the number of nodes in a binary tree that have exactly two children and the number of leaf nodes is 1 2. Deletion of root of AVL tree will take O(n) time so that, resulted tree also have property of AVL tree. I think first is false ... in second it is correct as we can do in logn so o(n) is also correct. Given answer is : 1 is true and second is false.
asked Dec 7, 2017 in DS rahul sharma 5 175 views
1 vote
2 answers
2
153 views
A 4-ary tree,i.e. each node has either 0 or 4 children tree has 20 leaf nodes. Then the total number of nodes in the tree are ____.
asked Nov 13, 2017 in DS Hardik Vagadia 153 views
0 votes
2 answers
3
375 views
assume the preorder tŕaversal of binary tree is "abc" how many total different binary trees are possible whose postorder traversal.is "cba" with the given preorder traversal.?? how to find it ?
asked Dec 7, 2017 in Programming aaru14 375 views
...