in DS edited by
12,137 views
29 votes
29 votes

In the balanced binary tree in the below figure, how many nodes will become unbalanced when a node is inserted as a child of the node “g”?

  1. $1$
  2. $3$
  3. $7$
  4. $8$
in DS edited by
12.1k views

3 Answers

33 votes
33 votes
Best answer

(B).

$a,b,c$ will become unbalanced with Balance factor as $+2,+2,+2$ respectively. Balance factor should be $-1,0,+1$.

Balance factor =  Height(LST) - Height(RST)

Or  Balance factor = | Height(LST) - Height(RST) |

edited by
13 votes
13 votes

a,b and c are unbalanced 

edited by

2 Comments

Rishi yadav what s the height of leaf node you have taken while calculating the B.F.?

0
0

May be this help you if any correction comment here thank u

1
1
0 votes
0 votes

Answer is b and the resultant tree you get after insersion is the following

 

Answer:

Related questions