Data Structures & AlgorithmsHardGATE CS · ICPC regional

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

  1. A. GDBCAEF
  2. B. AGDBCEF
  3. C. FAEBGDC
  4. D. FECABDG

Correct answer: A. GDBCAEF

The root is the first preorder letter, and splitting the inorder sequence gives the subtrees; this yields postorder GDBCAEF. 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