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
GATE CSE 2014 Set 3 · Q12
Time

Select one answerSingle correct
Solution
Official answer: A) SQPTRWUV
TreesFor a general/multi-way tree, the in-order traversal of a node with children is defined as:
In-order traversal of the first (leftmost) subtree
Visit the root node
In-order traversal of the remaining subtrees in order
Applying this recursively:
Root has children and .
Subtree at :
has child .
In-order traversal of : Visit , then visit .
Visit root .
Subtree at :
has three children: , , .
Traverse first child .
Visit node .
Traverse second child (which has child ): Visit , then visit .
Traverse third child .
In-order of subtree : .
Combining these gives the complete sequence: (SQPTRWUV), corresponding to Option A.
Try the question first, then check your work.
Examiner trap
In a general rooted tree, in-order traversal visits the leftmost child's subtree, then the root itself, and then the remaining children's subtrees in left-to-right order.
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
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.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
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 TreesIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.