GATE / CS ARCHIVE

GATE CSE 2026 SET 2 / QUESTION 12

Recognizing binary-tree traversal order

Data Structures · Tree Properties & Traversals · Full GATE CSE 2026 Set 2 paper

GATE 2026 Set 2, Q12 1 mark · MCQ
Report issue

Tree Properties & Traversals

Question 12, GATE 2026: Match I Inorder, II Preorder, III Postorder to L left-node-right, M node-left-right, N left-right-node. Options: A I-L,II-M,III-N; B I-M,II-L,III-N; C I-N,II-M,III-L; D I-L,II-N,III-M.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Givens and goal

Match I Inorder, II Preorder, III Postorder to L left-node-right, M node-left-right, N left-right-node. Options: A I-L,II-M,III-N; B I-M,II-L,III-N; C I-N,II-M,III-L; D I-L,II-N,III-M.

Approach

Locate the current node relative to its two recursively traversed subtrees.

Step-by-step solution

1. In an inorder traversal the current node is visited between its left and right subtrees: left, node, right. Therefore I matches L.
2. In preorder the current node is visited before either subtree: node, left, right. Hence II matches M. In postorder it is visited after both: left, right, node, so III matches N.
3. For a root r with left leaf l and right leaf t, these orders yield l,r,t; r,l,t; and l,t,r respectively. The same definition applies recursively at every internal node, not only at the root.
4. The combined matching is I-L, II-M, III-N, option A. In a BST, inorder also produces sorted keys, but the traversal definitions themselves apply to all binary trees.

Original paper, page 11 · Answer key