Data Structures & AlgorithmsVery hardCodeforces Div 2 · ICPC regional

Keys [49, 47, 26, 15, 3, 33, 12, 19, 21] are inserted, in this order, into an empty AVL tree using the standard rebalancing (left, right, left–right and right–left cases). How many rotation operations are performed in total, where a double rotation counts as two single rotations?

  1. A. 9
  2. B. 7
  3. C. 5
  4. D. 4

Correct answer: B. 7

The insertions trigger 5 rebalancing events; the double rotations add 2 each, giving 7 rotation operations. Counting events, or the final height, is not the same quantity.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic