Data Structures & AlgorithmsHardProduct-company placement

A binary search tree holds exactly the keys 13, 21, 40, 64, 69, 85, 92, 98. Which ONE of the following can be its POSTORDER traversal?

  1. A. 13, 40, 69, 85, 21, 64, 98, 92
  2. B. 85, 40, 21, 13, 69, 64, 98, 92
  3. C. 13, 40, 21, 85, 69, 64, 98, 92
  4. D. 13, 40, 21, 98, 69, 64, 85, 92

Correct answer: C. 13, 40, 21, 85, 69, 64, 98, 92

The last key is the root; the keys before it must split into a block of smaller keys followed by a block of larger keys, recursively. Only 13, 40, 21, 85, 69, 64, 98, 92 splits correctly at every level.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic