Data Structures & AlgorithmsHardProduct-company placement

The POSTORDER traversal of a BST with distinct keys is 10, 12, 25, 49, 53, 92, 88, 93, 76, 32. What are the height of the tree (edges on the longest root-to-leaf path) and its number of leaves?

  1. A. Height 5, leaves 3
  2. B. Height 4, leaves 3
  3. C. Height 4, leaves 4
  4. D. Height 3, leaves 2

Correct answer: B. Height 4, leaves 3

The last key 32 is the root; split the rest into smaller and larger blocks and recurse (or insert the reversed postorder into a BST). The rebuilt tree has level order 32, 25, 76, 12, 53, 93, 10, 49, 88, 92: height 4, 3 leaves.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic