Empty spot = −1, leaf = 0, every other node: h(v) = 1 + max(h(left), h(right)).
AVL rule
It is a binary search tree, and for every node |h(left) − h(right)| ≤ 1. Height is then O(log n).
Repair
z = first unbalanced node going up, y = its taller child, x = taller child of y. Sort into a < b < c: b becomes the root, a and c its children, T0…T3 keep their order.