DSA Lab
AVL rotations
An AVL tree is a binary search tree that repairs itself. After every insert it checks each node's balance (left height minus right height) on the way back up, and fixes a node at +2 or −2 with one or two rotations.
AVL rotations: how it works
In this tool: self-balancing, all four cases. Put in your own values and watch it change. Each operation runs one step at a time and says in plain words what happened, with its calculation worked out. The code is shown in Python, C, C++ or Java with the line that just ran marked, and an Understand it panel gives the idea, why it works, the cost of each operation, common mistakes and a short quiz.
Lessons that use it
- Binary search trees (Data Structures)Smaller keys to the left, larger to the right: insert, search, and delete with its three cases.
- AVL trees: self-balancing search trees (Data Structures)Keep a binary search tree's height close to log n by checking every node's balance after an insert and repairing it with rotations.