Your server's index is a binary search tree. Data packets are flooding in. Each one slides down the tree (smaller β β larger) and docks as a red leaf.
Click a node, then Left Rotate, Right Rotate or Recolor it.
The moment the whole tree is a valid red-black tree, GC wipes out every docked packet.
Let it lean: latency spikes eat your memory. Too deep: Stack Overflow.
click node Β· Q β² Β· W β Β· E β³ Β· arrows move
How to play
Packets (purple hexagons) enter at the top and walk down the tree by BST rules: smaller goes left, larger goes right. When they hit an empty slot they dock as a red node with a toxic dashed ring. Docked packets are dormant for a few seconds, then start leaking memory.
Whenever the entire tree satisfies every red-black rule, the tree lights up, Garbage Collection fires and every docked packet is destroyed for points. Clear a wave (all packets collected, tree valid) to compact memory and pick 1 of 3 patches.
Red-black rules
Rule 2
The root is black.
Rule 3
Empty (NIL) leaves count as black β always true here.
Rule 4
A red node never has a red child (orange pulsing edge).
Rule 5
Every path from a node down to a NIL leaf passes the same number of black nodes (yellow bh badge marks mismatches).
Failure modes
Latency spike
Tree depth H > 2Β·logβ(N+1): memory drains every second, faster the deeper you go.
Stack Overflow
H exceeds the call-stack limit (12 levels): instant crash.
Out of Memory
Memory hits 0 MB.
Controls
Click / tap
Select a node (floating menu appears)
Q Β· W Β· E
Left Rotate Β· Recolor Β· Right Rotate
Arrows
β parent, β left child, β right child
F
Rubber duck: auto-apply one insert fix-up step (limited charges per wave)
X
REINDEX: rebuild a perfect tree instantly for 20 MB (packets collected without points)
P / Esc
Pause
Rotations
Left Rotate(x): x's right child y moves up into x's place; x sinks to become y's left child; y's old left subtree becomes x's right subtree. Right Rotate is the mirror image. In-order (sorted) order never changes.