Data Structures & AlgorithmsHardGATE CS · TCS NQT · Product Company SDE

Keys 37, 28, 13, 54, 24, 77, 95, 49, 68 are inserted in this order into an empty BST. What is the preorder traversal?

  1. A. [24, 13, 28, 49, 68, 95, 77, 54, 37]
  2. B. [37, 28, 13, 24, 54, 49, 77, 68, 95]
  3. C. [13, 24, 28, 37, 49, 54, 68, 77, 95]
  4. D. [37, 13, 28, 24, 54, 49, 77, 68, 95]

Correct answer: B. [37, 28, 13, 24, 54, 49, 77, 68, 95]

Insert in order to build the BST (root 37); preorder visits root, left, right, giving [37, 28, 13, 24, 54, 49, 77, 68, 95].

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic