IAE Academy

GATE 2026 CS2 Q.12: solution and answer

GATE 2026 · CS2Q.12 · 1 mark · MCQ

The set T represents various traversals over binary tree. The set S represents the order of visiting nodes during a traversal.

| T | S |
|---|---|
| I: Inorder | L: left subtree, node, right subtree |
| II: Preorder | M: node, left subtree, right subtree |
| III: Postorder | N: left subtree, right subtree, node |

Which one of the following is the correct match from T to S ?

GATE 2026 CS2 question 12: A two-column table with header row 'T' and 'S'.Tap to open full size
Figure from the GATE 2026 CS2 paper. It is part of the question.
Figure description

A two-column table with header row 'T' and 'S'. Three data rows: Row 1: 'I: Inorder' | 'L: left subtree, node, right subtree'. Row 2: 'II: Preorder' | 'M: node, left subtree, right subtree'. Row 3: 'III: Postorder' | 'N: left subtree, right subtree, node'.

  1. (A)

    I – L, II – M, III – N

  2. (B)

    I – M, II – L, III – N

  3. (C)

    I – N, II – M, III – L

  4. (D)

    I – L, II – N, III – M

Answer and solution

ANSWER

Option (A) is correct: I – L, II – M, III – N.

Official answer: ASource: Official answer key, GATE 2026 CS2 (IIT Guwahati)

  1. Inorder traversal visits the left subtree, then the node, then the right subtree. This is exactly description L.

  2. Preorder traversal visits the node first, then the left subtree, then the right subtree. This is exactly description M.

  3. Postorder traversal visits the left subtree, then the right subtree, then the node last. This is exactly description N.

  4. Therefore I (Inorder) – L, II (Preorder) – M, III (Postorder) – N.

  5. This exact mapping I–L, II–M, III–N is option (A).

KEY IDEA

Each binary tree traversal is defined purely by the relative order in which the node is visited with respect to its left and right subtrees: Inorder = Left, Node, Right; Preorder = Node, Left, Right; Postorder = Left, Right, Node.

WATCH OUT FOR

Confusing preorder and postorder — remembering "node visited first" or "node visited last" without anchoring it to the mnemonic (Pre = node before children, Post = node after children), which leads to swapping M and N.

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

More Trees & heaps questions