ISRO 2011 · Arrays & Matrix Representation

MCQ · 1 mark · Problem PROG-DSTR-0162

The in-order traversal of a complete binary tree with 7 nodes (all three levels full) 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

Solve it on GATE DA practice →More Basic Data Structures problems

Show the worked solution\[\boxed{\text{in a perfect tree, the root is the middle element of the in-order sequence}}\]Root A (middle of FBGADCE). Left subtree FBG has root B with children F and G; right subtree DCE has root C with children D and E.Pre-order (root, left, right): A B F G C D E.The shape matters: without it, the in-order sequence alone does not fix the tree (AFGBDEC is the pre-order of another tree with the same in-order sequence).Answer: B

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com