In an AVL tree of composers sorted alphabetically, Brahms is the left child of Bruckner, which is the left child of Dvorak. Inserting Beethoven breaks the balance. Where, and how is it repaired?
Beethoven becomes Brahms's left child. Bruckner now has balance factor +2 (left subtree height 1, right empty): z = Bruckner, y = Brahms, x = Beethoven, a left-left line. A single right rotation around Bruckner makes Brahms the subtree root with Beethoven and Bruckner as its children.
The tree before the insert (each line shows a node's children; ä counts as a, so Händel comes before Haydn):
Mozart
├── Dvorak
│ ├── Bruckner
│ │ └── Brahms (left child)
│ └── Haydn
│ ├── Händel
│ └── Milhaud
│ ├── Mahler
│ └── Monteverdi
└── Schubert
├── Schostakowitsch
└── Schumann
└── Telemann (right child)
Search: Beethoven < Mozart, < Dvorak, < Bruckner, < Brahms (Be before Br), so it becomes Brahms's left child.
Balance factors, walking up: Brahms +1, Bruckner +2 (the first violation), so z = Bruckner. Its taller child is y = Brahms, and Brahms's taller child is x = Beethoven. Both steps go left: a straight line.
Single right rotation around Bruckner: Brahms moves up into Bruckner's place under Dvorak, with Beethoven on its left and Bruckner on its right. Afterwards Brahms 0, Dvorak −1 (left height 1, right height 2), Mozart +1. One rotation, and the whole tree is balanced again.