Binary Search Tree Rotations
Left Rotate
Essentially shifts elements towards the left
- Right child of root node becomes the new root node
- Left child of right child will slide over and become the right child the old root node
- Remember to update references, such as parent or children references, if needed
Right Rotate
Esssentially shifts elements towards the right
- Left child of root node becomes the new root node
- Right child of left child will slide over and become the left child the old root node
- Remember to update references, such as parent or children references, if needed
For more info, check out
w3schools