Red-Black Tree Visualization

Self-balancing binary search tree with guaranteed O(log n) operations

Red-Black Tree Properties

1. Nodes are either red or black
2. Root is always black
3. All leaves (NIL) are black
4. Red node cannot have red children
5. Same black height for all paths

Tree Structure

Tree is empty. Insert nodes to see the Red-Black Tree structure!

Tree Statistics

Nodes: 0
Height: 0
Root: null
Balanced: Yes

Time Complexities

Search: O(log n)
Insert: O(log n)
Delete: O(log n)
Space: O(n)

Node Colors

Red Node
Black Node
Highlighted

Advantages of Red-Black Trees

⚡ Performance

Guaranteed O(log n) operations

⚖️ Balanced

Self-balancing structure

🔄 Dynamic

Efficient insertions & deletions

📊 Used In

STL map, Java TreeMap