The Gateway to Computer Science Excellence
0 votes
153 views

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, -, *, +
in Unknown Category by
edited by | 153 views
0
(b) is the answer

2 Answers

+2 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)

by
edited by
+1 vote

So, The answer is option B)

by
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
52,315 questions
60,427 answers
201,750 comments
95,226 users