Red-Black Tree Rotation Case Explorer
Step through the exact insertion fix-up cases of a red-black tree in 3D: uncle-red recoloring, and the LL/RR/LR/RL rotation cases, with live black-height and rotation-count readouts.
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.
Step through the exact red-black tree insertion fix-up cases — uncle-red recoloring and the LL/RR/LR/RL rotation shapes — in an animated 3D tree with live black-height and rotation-count readouts.
3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install