edited by
448 views
0 votes
0 votes

If the post order traversal of tree

gives $ab - cd * +$, then the label of the nodes A, B, C, ......, G will be

  1. a, -, b, +, c, *, d
  2. +, -, *, a, b, c, d
  3. -, a, +, b, c, d, *
  4. a, b, c, d, -, *, +
edited by

2 Answers

3 votes
3 votes

In post-order traversal , we've to

  1. Traverse the left sub-tree of root
  2. Traverse the right sub-tree of root
  3. Visit the root

The nodes are visited in post-order as D  E  B  F  G  C  A

& according to the question D  E  B  F  G  C  A equals to ab - cd * +

∴ D = a , E = b , B = -  , F = c , G = d , C = * , A = +

write the things sequentially

A = + , B = -  , C = * , D = a , E = b , F = c , G = d

the answer is Option B)

edited by

Related questions

1 votes
1 votes
2 answers
1
gatecse asked Mar 2, 2018
2,312 views
Which of the following problem cannot be solved without recursion?Tower of HanoiFibonacci seriesTree TraversalNone of the above
0 votes
0 votes
1 answer
2
gatecse asked Mar 2, 2018
339 views
If there is a graph such that there is a unique path between any pair of vertices. The graph is a ________MeshGridTreeBipartite graph
0 votes
0 votes
1 answer
3
gatecse asked Mar 2, 2018
5,991 views
Which of the following is not used for hash function?Mid-square methodDivision methodFolding methodProbe method
0 votes
0 votes
1 answer
4
gatecse asked Mar 2, 2018
1,325 views
Which of the following search method takes less memory ? Depth-first search Breadth-first search Linear search None of the above