The in-order traversal of a tree resulted in FBGADCE. Then the pre-order…

2011

The in-order traversal of a tree resulted in FBGADCE. Then the pre-order traversal of that tree would result in

  1. A.

    FGBDECA

  2. B.

    ABFGCDE

  3. C.

    BFGCDEA

  4. D.

    AFGBDEC

Attempted by 294 students.

Show answer & explanation

Correct answer: B

Concept

A binary tree is uniquely reconstructable only when an inorder traversal is paired with a preorder (or postorder) traversal: inorder fixes the left-right ordering, while preorder/postorder fixes which node is the root at each level. Inorder ALONE does not determine a unique tree, so in principle several different preorder strings can match one inorder string.

To make such a problem well-posed, the standard convention (and the one the ISRO key uses) is to assume a complete / balanced binary tree, built by recursively choosing the MIDDLE element of each inorder segment as that segment's root.

Application

Apply the middle-as-root rule to the inorder string FBGADCE:

  1. Whole segment FBGADCE -> middle element A becomes the root; everything left of A (FBG) is the left subtree, everything right of A (DCE) is the right subtree.

  2. Left segment FBG -> middle element B is its root, with F as B's left child and G as B's right child.

  3. Right segment DCE -> middle element C is its root, with D as C's left child and E as C's right child.

Now read this tree in preorder (root, then left subtree, then right subtree): A, then the left subtree B F G, then the right subtree C D E.

Preorder result: ABFGCDE.

Cross-check

Read the constructed tree back in inorder (left, root, right): left subtree gives F B G, then root A, then right subtree gives D C E -> FBGADCE, which matches the given inorder exactly. So the complete-tree reconstruction is consistent.

Note on the reported ambiguity: because only the inorder was supplied, AFGBDEC is also a mathematically valid preorder for FBGADCE (it corresponds to a different, skewed tree). The exam, however, fixes the intended tree with the complete/balanced convention above, and the official ISRO 2011 key is ABFGCDE. The solution therefore states ABFGCDE as the accepted answer while acknowledging that the bare inorder, on its own, is not enough to force a single tree.

Explore the full course: Isro