Data Structures & AlgorithmsVery hardGATE CS · Advanced

Keys 50, 20, 60, 10, 30, 40, 70, 45, 42, 48, 5, 3 are inserted one by one, in this order, into an initially empty AVL tree. A double rotation counts as two rotations. What is the key at the root at the end and how many rotations were performed in total?

  1. A. root 42, 8 rotations
  2. B. root 42, 9 rotations
  3. C. root 42, 7 rotations
  4. D. root 50, 8 rotations

Correct answer: A. root 42, 8 rotations

Simulate with balance checks after every insertion: final root 42, 8 rotations (a double rotation is two). The unbalanced BST would keep 50 as root with height 6, which an AVL tree does not allow.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic