Data Structures & AlgorithmsVery hardProduct-company placement

A binary tree with distinct labels has INORDER G H B F C E A D I and LEVEL-ORDER I E G D F A H C B. What is its postorder traversal?

  1. A. I E G F H B C D A
  2. B. B H C F G A D E I
  3. C. A D C B H F G E I
  4. D. B C H A F D G E I

Correct answer: B. B H C F G A D E I

The first level-order label I is the root; its position in the inorder splits the left and right subtrees, and the earliest level-order label inside each part is that part's root. Rebuilding gives postorder B H C F G A D E I.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic