edited by
16,266 views
50 votes
50 votes

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

  1. $SQPTRWUV$
  2. $SQPTUWRV$
  3. $SQPTWUVR$
  4. $SQPTRUWV$
edited by

9 Answers

Best answer
57 votes
57 votes

Correct Option: A

The inorder traversal order of a ternary tree is left $\rightarrow $ root $\rightarrow $ middle $\rightarrow $ right.

edited by
19 votes
19 votes

The inorder traversal of a ternary tree is given by Left > Root > Middle > Right.

But if you apply this traversal sequence on this tree, the order is SQPTWURV.

According to the answer given by various books, the answer is (A).

(A) can only be the answer if we consider 'S' to be the left child of 'Q', and 'W' to be the left child of 'U'.

11 votes
11 votes
For inorder traversal you can take a trick
whenever you visit the node second time take it into inorder sequence.. :D
4 votes
4 votes
Inorder transversal of ternary tree is :- left -> Root->Middle->Right

from the given figure, it is not clear whether W is middle child of U or left child of U

if W is middle child of U then  SQPTRUWV (option D)

if W is left child of U then       SQPTRWUV  (option A)
Answer:

Related questions