Answer to Question balance-2
Using the basic algorithm yields the following tree.
10
/ \
/ \
5 15
/ / \
/ / \
2 12 20
/ / \
/ / \
11 18 21
\
\
25
Walking back up the path to the newly inserted node,
all of the nodes are height-balanced except the root,
holding 10. Two steps downward from there toward the
higher subtree takes two steps to the right, so this
is a zig-zig, calling for a single rotation. After
doing that single rotation, the tree is as follows.
15
/ \
/ \
/ \
10 20
/ \ / \
/ \ / \
5 12 18 21
/ / \
/ / \
2 11 25