Picturing AVL rotations as a see-saw
I'm a visual learner, so here's how I picture AVL trees: every node is a see-saw, and its balance factor is how far it tips (left height minus right height).
A node is fine while it tips by at most one. The moment an insert or delete makes it tip by two, you rotate.
For a single rotation, grab the heavier child and lift it up to where its parent was. The parent slides down to the lighter side, and the child's inner subtree gets handed across to the parent. Picture it as sliding the fulcrum over one spot.
Double rotations happen when the heavy side is heavy on the inside, like a zig-zag. Straighten the zig-zag with a rotation at the child first, and then it's a normal single rotation at the top.
What made it click: after any rotation, the new top node always ends up perfectly level, and nothing above it needs rebalancing on insert.
Comments
The see-saw picture is so much easier to remember than the balance factor table.