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

Keys 40, 26, 84, 95, 87, 62, 49, 79 are inserted one by one into an empty binary search tree. What is the in-order traversal?

  1. A. [26, 40, 49, 62, 79, 84, 87, 95]
  2. B. [26, 49, 79, 62, 87, 95, 84, 40]
  3. C. [40, 26, 84, 62, 95, 49, 79, 87]
  4. D. [40, 26, 84, 62, 49, 79, 95, 87]

Correct answer: A. [26, 40, 49, 62, 79, 84, 87, 95]

Build the BST by inserting in order (root 40). in-order gives [26, 40, 49, 62, 79, 84, 87, 95]. In-order of a BST is always sorted.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic