Data Structures & AlgorithmsVery hardProduct-company placement

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

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

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

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic