IAE Academy

GATE 2026 DA Q.25: solution and answer

GATE 2026 · DAQ.25 · 1 mark · MSQ

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.

Pre-order: P Q S E R F G
In-order: S Q E P F R G

Which of the following statements is/are true about the Binary Tree T?

  1. (A)

    Node 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 Q has only one child

  4. (D)

    The left subtree of node R contains the node G

See the question in the paper

Answer and solution

ANSWER

Statements (A) and (B) are true; (C) and (D) are false.

Official answer: A, BSource: Official answer key, GATE 2026 DA (IIT Guwahati)

  1. The first node in the pre-order is the root, so the root of is . Statement (A) is true.

  2. In the in-order, the nodes to the left of are (left subtree, 3 nodes) and the nodes to the right are (right subtree, 3 nodes). So the pre-order splits as , then (left subtree), then (right subtree).

  3. Left subtree: its pre-order is , so its root is . In its in-order , lies left of and lies right of . Hence has left child and right child . Node has two children, so (C) is false.

  4. Right subtree: its pre-order is , so its root is . In its in-order , lies left of and lies right of . Hence has left child and right child .

  5. The left subtree of is just . Node is in the right subtree of , so (D) is false.

  6. Post-order is left subtree, right subtree, root. Left subtree gives . Right subtree gives . Then the root . The post-order is , which matches (B), so (B) is true.

  7. Only (A) and (B) are true.

KEY IDEA

The first node of the pre-order is the root; its position in the in-order splits the remaining nodes into the left and right subtrees. Repeat on each part, using the subtree sizes to cut the pre-order.

WATCH OUT FOR

Splitting the pre-order at the wrong place, or treating a node as having only one child without checking both sides of it in the in-order. Here has on its left and on its right, so (C) is false. Another slip is thinking is in 's left subtree, when it appears after in the in-order.

From the GATE 2026 DA paper. Every question of this paper · Download the full paper · All 26 Trees & heaps questions, with notes

More Trees & heaps questions