Data Structures & AlgorithmsHardProduct-company placement

Keys 53, 59, 94, 71, 34, 76, 82, 15, 62, 24 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. 3 rotations, root 59
  2. B. 4 rotations, root 53
  3. C. 4 rotations, root 59
  4. D. 5 rotations, root 59

Correct answer: C. 4 rotations, root 59

The rebalancing events are RR at 53, LR at 94, LL at 53: 2 single and 1 double, i.e. 2 + 2×1 = 4 rotations; the root ends as 59.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic