in DS retagged by
6,487 views
3 votes
3 votes

A balance factor in AVL tree is used to check

  1. what rotation to make
  2. if all child nodes are at same level
  3. when the last rotation occurred
  4. if the tree is unbalanced
in DS retagged by
by
6.5k views

1 comment

@Sachin Mittal 1  Sir ,balance factor is used to check whether the avl tree is balanced or not … but in answer key in gateoverflow book of nielit pyq answer is given that it is used to see which rotation to make . could you kindly clarify which one is correct ?

1
1

2 Answers

5 votes
5 votes
A balancing factor in the AVL tree is used to check whether the tree is balanced or not.

Balance Factor of Node A = Height of right subtree of A - Height of left subtree of A.

The allowed balance factors are {-1,0,1}. Otherwise, the node is unbalanced.

If any node is unbalanced we cannot guarantee O(log n) search time. Therefore, AVL tree uses the concept of Balance Factor.

Hence, Option D is the correct option.
1 vote
1 vote
AVL trees are self balancing therefore have BF [-1,0,1]. The BF is checked to guess the rotation in tree. Option 3 is correct.
Answer:

Related questions