1

30kviews

Insert the following elements in AVL Tree 44, 17, 32, 78, 50, 88, 48, 62, 54. Explain the different rotations that will be used.

**1 Answer**

1

30kviews

Insert the following elements in AVL Tree 44, 17, 32, 78, 50, 88, 48, 62, 54. Explain the different rotations that will be used.

1

1.5kviews

written 8.2 years ago by |

The different rotations that were used are:

**1) LR rotation :**

- Here the new node is inserted in the left sub-tree of the left sub-tree of critical node.
- This rotation was used in step 4. Here 44 was the critical node.
- Here we need to carry out a rotation. After the rotation 32 became root node and the tree was balanced

**2) RR rotation:**

- Here the new node is inserted in the right sub-tree of the right subtree of the critical node.
- This rotation was used in step 9 in the above example. Here 32 was the critical node after 88 was inserted into it.
- Here we need to carry out a rotation. After rotation the tree gets balanced.

**3) RL rotation:**

- Here the new node is inserted in the right sub-tree of the left sub-tree of the critical node.
- This rotation was used in step 7 in the above example. Here 44 was the critical node after 50 was added to the tree.
- Here we need to carry out a rotation. After then RL rotation, the tree gets balanced

ADD COMMENT
EDIT

Please log in to add an answer.