Data Structures & AlgorithmsHardGATE CS · Product-company placement

Keys 88, 38, 16, 75, 87, 68, 51, 36, 82, 61 are inserted in order into an empty AVL tree. Counting a double rotation as two single rotations, how many single rotations are performed in total, and what is the final root?

  1. A. 4 rotations, root 75
  2. B. 7 rotations, root 88
  3. C. 7 rotations, root 75
  4. D. 8 rotations, root 75

Correct answer: C. 7 rotations, root 75

The rebalancing events are LL at 88, LR at 88, RL at 38, LR at 68: 1 single and 3 double, i.e. 1 + 2×3 = 7 rotations; the root ends as 75.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic