The Gateway to Computer Science Excellence
+1 vote

in DS by Active (4.1k points)
edited by | 1k views
in a sight,it looks like AVL tree, i have not solved though!!
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 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!
by Boss (18k points)
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??
As far as i am concerend!!

How was the CBT 1?   i mean difficulty?
Not up to the GATE Level .
can you explain difference between option c and d
i a myself confused!! i
Why not D ?
I marked option D too. They say it's C. I think they framed the wrong options.
No , i got it Now .
See AVL is height Balanced  BST . But they give size balanced tree.
Both are different . So, option C correct .
But in option d,  the definition they gave for size balanced tree,  isn't it same as an AVL tree?
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,279 answers
104,838 users