GATE DA 2026 · Trees

MSQ · 1 mark · Problem PROG-DSTR-0062

You are given the following Pre-order and In-order traversals of a Binary Tree \(T\) with nodes \(E, F, G, P, Q, R, S\).\[\begin{array}{llllllll} \text{Pre-order:} & P & Q & S & E & R & F & G \\ \text{In-order:} & S & Q & E & P & F & R & G \end{array}\]Which of the following statements is/are true about the Binary Tree \({T}?\)
  1. A
    Node \(\text{P}\) is the root of \(T\)
  2. B
    The Post-order traversal of \(T\) is: S E Q F G R P
  3. C
    Node \(\text{Q}\) has only one child
  4. D
    The left subtree of node \(\text{R}\) contains the node \(\text{G}\)

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

Show the worked solutionGiven traversals of tree \(T\) on nodes \(E,F,G,P,Q,R,S\), reconstruct the tree using the standard technique: the first element of Preorder is the root; find that root in Inorder to split the remaining nodes into left and right subtrees; recurse.Working through the given Preorder/Inorder sequences this way reconstructs a unique tree with P as the root, confirming that option. Reading off the tree structure obtained, tracing a postorder traversal (left, right, root at every level) produces exactly S E Q F G R P, confirming that option as well.Checking the other two claims against the reconstructed tree: node \(Q\) is found to have two children (not just one), so that claim is false; and node \(G\) is not found within \(R\)'s left subtree in the reconstructed structure, so that claim is also false.Answer: P is the root of T; and the postorder traversal is S E Q F G R P.Click Here for Detail SolutionGateOverflow discussion: https://gateoverflow.in/523200/gate-da-2026-question-15

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