Data Structures & AlgorithmsHardGATE CS · ICPC regional · Product Company SDE

Keys 75, 97, 65, 30, 69, 78, 44, 25, 18 are inserted one by one into an empty binary search tree. What is the pre-order traversal?

  1. A. [18, 25, 44, 30, 69, 65, 78, 97, 75]
  2. B. [75, 65, 30, 25, 18, 44, 69, 97, 78]
  3. C. [75, 65, 97, 30, 69, 78, 25, 44, 18]
  4. D. [18, 25, 30, 44, 65, 69, 75, 78, 97]

Correct answer: B. [75, 65, 30, 25, 18, 44, 69, 97, 78]

Build the BST by inserting in order (root 75). pre-order gives [75, 65, 30, 25, 18, 44, 69, 97, 78]. The other traversals of the same tree are the distractors.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic