Skip to content
Official PYQ · 2026

GATE CS 2026 Set 2 Q2 — Trees

Explain with AI

The set T\mathbf{T} represents various traversals over binary tree. The set S\mathbf{S} represents the order of visiting nodes during a traversal.
TSI: InorderL: left subtree, node, right subtreeII: PreorderM: node, left subtree, right subtreeIII: PostorderN: left subtree, right subtree, node\begin{array}{|l|l|} \hline \quad\quad\textbf{T} & \quad\quad\quad\textbf{S} \\ \hline \text{I: Inorder} & \text{L: left subtree, node, right subtree} \\ \text{II: Preorder} & \text{M: node, left subtree, right subtree} \\ \text{III: Postorder} & \text{N: left subtree, right subtree, node} \\ \hline \end{array}
Which one of the following is the correct match from T\mathbf{T} to S\mathbf{S} ?

Choose one option
View worked solution

Answer: A

In binary tree traversals, the naming (Pre, In, Post) refers to the position of the current node relative to its left subtree and right subtree:

  • Inorder (I): The node is visited in-between the left and right subtrees.
    Order: left subtree → node → right subtree\text{Order: left subtree } \rightarrow \text{ node } \rightarrow \text{ right subtree}This matches L.
  • Preorder (II): The node is visited before (pre) the left and right subtrees.
    Order: node → left subtree → right subtree\text{Order: node } \rightarrow \text{ left subtree } \rightarrow \text{ right subtree}This matches M.
  • Postorder (III): The node is visited after (post) the left and right subtrees.
    Order: left subtree → right subtree → node\text{Order: left subtree } \rightarrow \text{ right subtree } \rightarrow \text{ node}This matches N.

Therefore, the correct matching is I−L,II−M,III−N\mathrm{I}-\mathrm{L}, \mathrm{II}-\mathrm{M}, \mathrm{III}-\mathrm{N}, which corresponds to option A.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Trees questions