The postorder traversal of a binary tree is DEBFCA. Which of the following can…
2011
The postorder traversal of a binary tree is DEBFCA. Which of the following can be a preorder traversal of the same tree?
Answer: C. ABDECF — ConceptPostorder visits a node only after traversing its left and right subtrees, whereas preorder visits the node before its subtrees. Therefore, the last…
- A.
ABFCDE
- B.
ADBFEC
- C.
ABDECF
- D.
ABDCEF
Attempted by 64 students.
Show answer & explanation
Correct answer: C
Concept
Postorder visits a node only after traversing its left and right subtrees, whereas preorder visits the node before its subtrees.
Therefore, the last symbol in postorder and the first symbol in preorder must be the same root. The remaining symbols must admit consistent left-subtree and right-subtree blocks in both traversals.
Application
The postorder sequence ends in A, so A must be the root. Every candidate begins with A and passes this first condition.
Test ABDECF by taking DEB as the left-subtree postorder and FC as the right-subtree postorder. Their roots are B and C, respectively.
For the left subtree, postorder DEB corresponds to root B with D and E as its two leaves, giving preorder BDE.
For the right subtree, postorder FC corresponds to root C with F as its single child, giving preorder CF.
Combining root, left preorder, and right preorder gives A + BDE + CF = ABDECF.
Cross-check and contrast
ABFCDE cannot be partitioned into subtree preorder blocks whose postorders concatenate to DEBFC.
ADBFEC places D immediately after A, but no compatible root-subtree partition then produces DEBFC before A.
ABDECF has the compatible blocks BDE and CF, which reproduce DEB and FC in postorder.
ABDCEF orders the B-subtree candidates as D then C before E and F, so no consistent subtree partition reproduces DEBFC.
Result
Thus, the possible preorder traversal among the given choices is ABDECF.