← All tree operations
AVL Rotation
ComparingInsertedUnbalancedRotating
binary search tree
left is smaller, right is larger
10
20
30
pseudocode
balance(node) = height(node.right) - height(node.left)if |balance| > 1: node is unbalanced(LL/RR: single rotation, LR/RL: rotate child first)if the child leans the opposite way: rotate the child firstrotateLeft/rotateRight(node): pivot takes node's placereattach pivot where node used to be
Frame 1 / 4
Starting tree
3 values inserted
4
3–9 unique integers, 1–99 each — inserted in order to build the starting tree.