Data Structures & AlgorithmsVery hardGATE CS

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

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

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic