Question
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?
Official answer and solution
- Official answer
- A
- From
- Official GATE 2026 answer key
Solution
Match each standard depth-first binary tree traversal with the position of the root node relative to its left and right subtrees.
By definition:
- Inorder (I) visits the left subtree, then the node, then the right subtree (L).
- Preorder (II) visits the node first, then the left subtree, then the right subtree (M).
- Postorder (III) visits the left subtree, then the right subtree, and finally the node (N).
Therefore, I - L, II - M, III - N is the correct matching.
Final answer
Option (A)
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2026 Computer Science and Information Technology - Session 2 (CS2)
- Question
- 12 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.