ISRO 2017 · Arrays & Matrix Representation

MCQ · 1 mark · Problem PROG-DSTR-0120

The 7 nodes of a binary tree are numbered 1 to 7 level by level, left to right: node 1 is the root, nodes 2 and 3 are its left and right children, nodes 4 and 5 are the left and right children of node 2, and nodes 6 and 7 are the left and right children of node 3.If the postorder traversal of the tree gives \(a\;b\;-\;c\;d\;*\;+\), then the labels of the nodes 1, 2, 3, ..., 7 will be
  1. A
    + , -, *, a,b,c,d
  2. B
    a, -,b,+,c,*,d
  3. C
    a,b,c,d,-,*,+
  4. D
    -,a,b,+,*,c,d

Solve it on GATE DA practice →More Basic Data Structures problems

Show the worked solutionPostorder (left, right, node) visits the nodes in the order 4, 5, 2, 6, 7, 3, 1.Matching with \(a\;b\;-\;c\;d\;*\;+\): node 4 = a, 5 = b, 2 = \(-\), 6 = c, 7 = d, 3 = \(*\), 1 = \(+\).Labels of nodes 1 to 7: \(+, -, *, a, b, c, d\) (the tree of \((a-b)+(c*d)\)).Answer: A

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com