Question 12

Consider the following expression tree. Tree: root is '+'; its left child is 'a' and its right child is '*'; the '*' node has left child 'b' and right child…

Consider the following expression tree. Tree: root is '+'; its left child is 'a' and its right child is '*'; the '*' node has left child 'b' and right child 'c'. In-order, pre-order and post-order traversal of this tree will result into which of the following expressions, respectively.
  1. Aa+bc*, +a*bc, abc*+
  2. Ba+b*c, +abc*, abc*+
  3. Ca+b*c, +a*bc, abc*+
  4. Da+b*c, +a*bc, abc+*
Show answerHide answer

Correct answer: (C) a+b*c, +a*bc, abc*+

Explanation

In-order (left, root, right) gives a+b*c, pre-order (root first) gives +a*bc, and post-order (root last) gives abc*+.

From DSSSB TGT Computer Science Practice Set 5

This is question 12 of DSSSB TGT Computer Science Practice Set 5. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.