

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 10
click for more info
Not enough gems
Cost: 6 gems
1: Unbalanced Trees
incomplete
2: Red-Black Tree
incomplete
3: Rules
incomplete
4: Rotation
incomplete
5: Fix Insert
incomplete
6: Quiz
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
"Rotations" are what actually keep a red-black tree balanced. Every time one branch of the tree starts to get too long, we will "rotate" those branches to keep the tree shallow. A shallow tree is a healthy (fast) tree!
O(1) operationsHere's the pointer-update order for a left rotation:
Now that we can add users to our new Red Black Tree, we need to add the rotation functionality that will keep it balanced and running fast!
Use the exact same variables as specified in the instructions. For example, pivot_parent and pivot.parent are not interchangeable as they hold state that changes throughout the algorithm's steps.