Single Left Rotation

  • Describe Single Left Rotation.

Consider inserting the values 3,5,73, 5, 7 in that order.

We start by inserting 33:

We have a BST with a single node; it is balanced!

Next, we insert 55.

Now our BST has two nodes. Notice the height and balance factor of the root has changed (and it is still balanced).

Next, we insert 77.

Our BST has three nodes now. Notice the heights and balance factors of the parent and grand parent of 77 have changed. In particular, the grandparent (the root) is not balanced anymore!

However, if we were to push 33 to the left of 55, we would restore balance:

This is called a (single) left rotation:

Notice the violation of balance property occurred in the grandparent of the newly inserted node. From the perspective of the grandparent node, the problem was caused in right child's right subtree. The solution is a (single) left rotation to bring the parent node (median value) above the grandparent (high value).