Data Structures & AlgorithmsVery hardCodeforces Div 2 · ICPC regional

Keys [2, 42, 28, 49, 8, 35] 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. 3
  2. B. 1
  3. C. 2
  4. D. 6

Correct answer: C. 2

The insertions trigger 1 rebalancing events; the double rotations add 2 each, giving 2 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