Goal:
Our goal is to manipulate with the structure of the tree.
Usually when restructuring, the number of nodes will stay the same but its heights are going to change.
There are two types of rotations:
- Left Rotation:
- Right Rotation:
This is how left rotation happens:
Steps for left rotations:
- First we note the parent and a child node.
- Then we try to rotate it in whatever form it is initially to rotate to the right side,
and make sure the subtree places do not change.
- Example:
- After the rotation the:
- Parent is: 'C', its left Child is: 'P' and its right subtree is: 'c'.
- Left Child is: 'P' and its left subtree is: 'a' and its right subtree is: 'b'.
To see more information about BST rotations, and specifically right rotations click: here