Question
Official answer and solution
- Official answer
- A
- From
- Official GATE 2014 answer key
Solution
Apply the multi-way tree in-order traversal definition: visit the first child's subtree, visit the node, then visit remaining children.
For a general rooted tree, the standard in-order traversal recursively performs:
- In-order traversal of the first (leftmost) child's subtree.
- Visit the current node.
- In-order traversal of the remaining children's subtrees from left to right.
Applying this traversal to the tree rooted at P:
-
Root P:
Children of P are Q (first child) and R (second child).- Step 1: Traverse subtree at Q.
- Q has one child S.
- Traverse subtree at S: visit S.
- Visit Q.
- Sequence for Q's subtree:
S Q.
- Step 2: Visit root P.
- Step 3: Traverse subtree at R.
- Children of R are T, U, V.
- Traverse first child T: visit T.
- Visit node R.
- Traverse second child U:
- U has child W: visit W.
- Visit U.
- Traverse third child V: visit V.
- Sequence for R's subtree:
T R W U V.
- Step 1: Traverse subtree at Q.
-
Combine sequences:
This gives SQPTRWUV, which corresponds to option A.
A
Using binary tree in-order intuition on R's three children without properly placing R after its first child T.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2014 Computer Science and Information Technology (CS) Session 3
- Question
- 22 of 65, printed as CS Q.12
- 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.