Data Structures & AlgorithmsVery hardGATE CS · Product-company placement

Keys 32, 44, 47, 53, 93, 54, 12, 22, 68, 97 are inserted into an empty AVL tree (giving preorder 53, 44, 22, 12, 32, 47, 68, 54, 93, 97). Then 22 and 47 are deleted in that order (a two-child node takes its inorder successor) with AVL rebalancing. What is the final preorder?

  1. A. 53, 32, 12, 44, 68, 54, 93, 97
  2. B. 53, 44, 32, 12, 68, 54, 93, 97
  3. C. 53, 44, 12, 32, 68, 54, 93, 97
  4. D. 44, 32, 12, 54, 53, 93, 68, 97

Correct answer: A. 53, 32, 12, 44, 68, 54, 93, 97

After each deletion walk back up and rotate at any node whose balance becomes ±2 (LL at 44). Skipping the rotation, or rebuilding the AVL tree from the remaining keys, gives a different tree.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic