RL Rotation

RL rotations is to be performed if the new node is inserted into the left of right sub-tree of the critical node A. Let us consider, Node B is the root of the right sub-tree of the critical node, Node C is the root of the sub-tree in which the new node is inserted.

Let T1 be the left sub-tree of the critical node A, T2 and T3 be the left and right sub-tree of Node C respectively, sub-tree T4 be the right sub-tree of Node B.

Since, RL rotation is the mirror image of LR rotation. In this rotation, the node C becomes the root node of the tree with A and B as its left and right children respectively. Sub-trees T1 and T2 becomes the left and right sub-trees of A whereas, T3 and T4 becomes the left and right sub-trees of B.

The process of RL rotation is shown in the following image.

RL Rotation in avl tree

Example

Insert node with the value 92 into the tree shown in the following figure.

RL Rotation in avl tree

Solution :

inserting 92 disturbs the balance factor of the node 92 and it becomes the critical node A with 105 as the node B and 95 with

RL Rotation in avl tree

the node C. In RL rotation, C becomes the root of the tree (as shown in the figure) with node A (90) and B (105) as its left and right children respectively. The tree will be rotated as shown in the figure.






Latest Courses