GateAI
Trees

GATE CSE 2014 Set 3 · Q12

MCQ1 markMedium

Time

Consider the following rooted tree with the vertex labeled P as the root: The order in which the nodes are visited during an in-order traversal of the tree is

GATE CSE 2014 Set 3 Q12 diagram

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: A) SQPTRWUV

Trees

For a general/multi-way tree, the in-order traversal of a node with children C1,C2,…,CkC_1, C_2, \dots, C_k is defined as:

  1. In-order traversal of the first (leftmost) subtree C1C_1

  2. Visit the root node

  3. In-order traversal of the remaining subtrees C2,C3,…,CkC_2, C_3, \dots, C_k in order

Applying this recursively:

  • Root PP has children QQ and RR.

  • Subtree at QQ:

    • QQ has child SS.

    • In-order traversal of QQ: Visit SS, then visit QQ   ⟹  S, Q\implies \text{S, Q}.

  • Visit root PP   ⟹  P\implies \text{P}.

  • Subtree at RR:

    • RR has three children: TT, UU, VV.

    • Traverse first child TT   ⟹  T\implies \text{T}.

    • Visit node RR   ⟹  R\implies \text{R}.

    • Traverse second child UU (which has child WW): Visit WW, then visit UU   ⟹  W, U\implies \text{W, U}.

    • Traverse third child VV   ⟹  V\implies \text{V}.

    • In-order of subtree RR: T, R, W, U, V\text{T, R, W, U, V}.

Combining these gives the complete sequence: S, Q, P, T, R, W, U, V\text{S, Q, P, T, R, W, U, V} (SQPTRWUV), corresponding to Option A.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Trees previous year question is Q12 of the GATE CSE 2014 Set 3 paper. Find more GATE CSE PYQs on Trees in Programming and Data Structures, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Trees PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Trees in GATE CSE

Trees has 13 GATE CSE PYQs across 11 papers from 2012 to 2026. 4 of them are 1-mark MCQs like this one, and GATE CSE 2014 Set 3 has 2.

How GATE tests Trees

More from GATE CSE 2014 Set 3

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2014 Set 3 · Q12 · MCQ

Consider the following rooted tree with the vertex labeled P as the root: The order in which the nodes are visited during an in-order traversal of the tree is

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.