Red node Black node Active in step
⚠ Couldn't load the 3D engineThree.js failed to load from the CDN. Check your connection and reload.

Red-Black Tree Rotation Case Explorer

Red-black trees stay balanced not by measuring height directly, like an AVL tree, but by enforcing a color invariant that a short local fix-up can always restore after an insertion. This simulator isolates that fix-up: pick one of the five textbook scenarios — a red uncle, or the LL / RR / LR / RL rotation shapes — and watch the exact sequence of recolorings and rotations the algorithm performs to eliminate a red-red violation, rendered as a live 3D tree with a gold highlight on the nodes each step touches. Insert Random Key grows the tree for real and runs whatever cases actually occur, including a Case-1 cascade climbing several levels, while the black-height and rotation-count readouts track the invariant that keeps every red-black tree at O(log n) height.