Data Structures & AlgorithmsVery hardGATE CS · Product-company placement

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

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

Correct answer: C. E D A C G F B H 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 E D A C G F B H I.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic