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

Keys 74, 72, 41, 18, 95, 79, 69 are inserted in this order into an empty BST. What is the preorder traversal?

  1. A. [18, 41, 69, 72, 74, 79, 95]
  2. B. [74, 41, 72, 18, 69, 95, 79]
  3. C. [18, 69, 41, 72, 79, 95, 74]
  4. D. [74, 72, 41, 18, 69, 95, 79]

Correct answer: D. [74, 72, 41, 18, 69, 95, 79]

Insert in order to build the BST (root 74); preorder visits root, left, right, giving [74, 72, 41, 18, 69, 95, 79].

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic