GATE Computer ScienceVery hardGATE CSE

Keys 10, 20, 30, 40, 50, 25, 5, 4, 3, 35, 45, 60, 55, 52 are inserted in this order into an initially empty AVL tree. Count every single rotation performed (a double rotation counts as two single rotations). What is the total number of single rotations?

  1. A. 9
  2. B. 8
  3. C. 7
  4. D. 11

Correct answer: B. 8

Rebalancing after each insertion (LL/RR = 1 rotation, LR/RL = 2) totals 8 rotations; the final root is 30.

More Programming and Data Structures (GATE) questions

Exams that ask this topic