Computer Science EngineeringHardISRO SC (CS)

The keys [10, 14, 40, 49, 41, 19, 38] are inserted in this order into an initially empty AVL tree. Its preorder traversal is:

  1. A. 10 14 40 19 38 49 41
  2. B. 49 41 38 19 10 14 40
  3. C. 40 14 10 19 38 41 49
  4. D. 10 14 19 38 40 41 49

Correct answer: C. 40 14 10 19 38 41 49

Insert with rotations to keep |balance| <= 1. Final tree has 5 rotation(s) in total (a double rotation counts as 2); preorder = 40 14 10 19 38 41 49. (Without balancing a plain BST would give 10 14 40 19 38 49 41.)

More Algorithms, Data Structures & Programming (ISRO CS) questions

Exams that ask this topic