Write BalanceFactors. Insert the input keys into a plain BST (no rebalancing). Then print, in increasing key order, each node's height (a leaf has height 0) and balance factor = height(left) − height(right), marking nodes with |balance| > 1.
If the tree is not an AVL tree, print how many nodes violate the condition, the key of the deepest violating node (where an AVL tree would rotate first) and which case it is: LL (one right rotation), RR (one left rotation), LR or RL (double rotations).
For the input
30 20 10
the program prints
BST with 3 keys, height 2
key 10: height 0, balance 0
key 20: height 1, balance +1
key 30: height 2, balance +2 <-- violates AVL
1 unbalanced node(s); fix first at key 30
Case LL: one right rotation