GATE / CS ARCHIVE

GATE CSE 2014 SET 3 / QUESTION 12

GATE CSE 2014 Set 3 Q12

Data Structures · Tree Properties & Traversals · Full GATE CSE 2014 Set 3 paper

GATE 2014 Set 3, Q12 1 mark · MCQ
Report issue

Tree Properties & Traversals

Question 12, GATE 2014: An ordered rooted tree has root P with children Q,R from left to right. Q has sole child S. R has children T,U,V from left to right. U has sole child W. Find the stated inorder visit sequence. A SQPTRWUV; B SQPTUWRV; C SQPTWUVR; D SQPTRUWV.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Our answer: A under the ordered-general-tree inorder convention

Step 1: Notice that R has three children, so ordinary binary-tree inorder is not sufficient to define the task. The keyed interpretation uses the ordered-tree extension: traverse the first child, visit the node, then traverse remaining children left to right. Step 2: Under that convention Q's subtree gives S,Q; P is next. R's subtree gives T,R, then U's subtree W,U, then V. Step 3: Concatenate to obtain S,Q,P,T,R,W,U,V, option A. The source's missing convention remains a qualification rather than silently treating the drawing as binary.

Original paper, page 55 · Answer key