Rotation

In this lesson, we'll discuss the rotation operation on a BST

We'll cover the following...

Before we discuss how self-balancing BST works, we must first understand the rotation operation on a subtree (left and right). While doing a rotation - BST property should stay intact.

Keeping the above points in mind, let’s see what a left rotation looks like.

Take a look at the below BST:

%0 node_1 A node_1716485480899 T1 node_1->node_1716485480899 node_1716485461615 B node_1->node_1716485461615 node_1716485494812 T2 node_1716485461615->node_1716485494812 node_1716485487110 T3 node_1716485461615->node_1716485487110

We want to perform a left rotation:

  1. BB becomes the root. Since key(A)<key(B)key(A) < key(B), AA
...