The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
124 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 Others by Boss (16.1k points)
edited by | 124 views
0
(b) is the answer

2 Answers

+1 vote

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 Boss (15.1k points)
edited by
+1 vote

So, The answer is option B)

by (185 points)

Related questions

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
49,807 questions
54,713 answers
189,262 comments
79,704 users