← 🌳 Algorithms & AI

🌳 AVL Rotation Lab

Nodes: 0
Height: 0
Rotations so far: 0
FPS:
balanced (0) leaning (±1) just rotated
Drag — rotate · Scroll — zoom

🌳 AVL Tree Rotations Explained

A self-balancing binary search tree rendered in 3D: every node's color reflects its live balance factor, and inserting or deleting a key triggers left, right or left-right/right-left rotations that visibly re-arrange the tree to keep it balanced.

🔬 What It Demonstrates

Each node tracks the height difference between its left and right subtrees (its balance factor). When an insert or delete pushes that value past ±1, the tree rotates nodes around the offending pivot, and the rotation log records exactly which rotation ran and where.

🎮 How to Use

Click "Insert random" or "Delete random" to modify the tree one key at a time, or switch on Auto-build to watch a continuous stream of insertions and deletions rebalance the tree on its own. Drag to orbit, scroll to zoom.

💡 Did You Know?

AVL trees, published in 1962 by Adelson-Velsky and Landis, were the first self-balancing binary search tree — guaranteeing O(log n) operations regardless of insertion order, decades before red-black trees became the default in most standard libraries.