1,544 views
2 votes
2 votes
Suppose we have an AVL tree of n nodes and any change in the tree violates the AVL tree property then :-
S1: If we insert an element in the tree, maximum 2 Rotations are required to make the Tree AVL again.
S2: If we delete an element from the tree, maximum 2 Rotations are required to make tree AVL again

Which are correct statements?

3 Answers

0 votes
0 votes

For insert 1 rotation is at most.
For delete the number of rotation is bounded by O(log(n)). Log(n) is the height of the tree.
More explanation on AVL deletion. When you delete a node from AVL you might cause the tree unbalanced, which you have to trace back to the point where it is unbalanced. If the unbalanced point is the root. You have to rebalance the tree from top to bottom.

Both false.

Ref: https://stackoverflow.com/questions/20912461/more-than-one-rotation-needed-to-balance-an-avl-tree

0 votes
0 votes
RL= LL+RR and LR=RR+LL.   So for insertions max 2 rotations (ie RR or LL or both) can be done but in case of deletion max 1 rotation (either RR or LL) is sufficient.  So S1 is true and S2 is false

Related questions

1 votes
1 votes
1 answer
1
kd..... asked Apr 13, 2019
794 views
here what to do first as FIZZA and IMRAN both are unbalanced than either to do RR rotation from FIZZA-IMRAN-NAVEEN or RL rotation from IMRAN-NAVEEN-LOVELY
2 votes
2 votes
3 answers
3
learncp asked Jan 26, 2016
788 views
Insert the given values in the order in initially empty $\text{AVL}$ tree.$\text{34,21,10,27,24,43,15,6}$What is the value at the root of the tree$?$
3 votes
3 votes
1 answer
4
hrcule asked Jul 16, 2018
2,770 views
Let T be a binary search tree with n nodes and Sn be the average number of comparisons required for successful search and Un be the average number of comparison required ...