Data Structures & AlgorithmsHardGATE CS · ICPC regional

A binary tree with distinct letters has preorder CHEGDBFA and inorder HECFBADG. What is its postorder traversal (left, right, root), written as a string of letters?

  1. A. EHFABDGC
  2. B. AFBDGEHC
  3. C. CHGEDBFA
  4. D. GDABFCEH

Correct answer: A. EHFABDGC

The root is the first preorder letter, and splitting the inorder sequence gives the subtrees; this yields postorder EHFABDGC. Reversing the preorder or taking a level-order walk gives a different string.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic