Data Structures & AlgorithmsVery hardGATE CS · Product-company placement

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

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

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

The first level-order label D 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 I F A E H C B G D.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic