Red-Black Tree
A Red-Black tree is a self-balancing binary search tree with an extra color bit per node (red or black). It maintains balance through a set of properties that guarantee the tree remains approximately balanced during operations.
Red-Black Tree Properties:
- Every node is either red or black
- The root is black
- All leaves (NIL) are black
- If a node is red, then both its children are black
- Every path from root to leaves has the same number of black nodes
Time Complexity:
- Search: O(log n)
- Insert: O(log n)
- Delete: O(log n)
Use the controls above to perform operations on the Red-Black tree. Watch how the tree maintains its balance through color changes and rotations.