The Gateway to Computer Science Excellence
+1 vote
1.7k views

Consider the In-order and Post-order traversals of a tree as given below:

In-order: j e n k o p b f a c l g m d h i

Post-order: j n o p k e f b c l m g h I d a

The Pre-order traversal of the tree shall be

  1. a b f e j k n o p c d g l m h i
  2. a b c d e f j k n o p g l m h i
  3. a b e j k n o p f c d g l m h i
  4. j e n o p k f b c l m g h I d a
in Others by Veteran (105k points)
retagged by | 1.7k views

1 Answer

+4 votes

If we consider given In-order and Post Order and construct the tree then no option is going to match .

                  

This is the tree with given in-order  and post-order

If you traverse it from top to bottom left to right and print each element second time then we are going to get the exact in-order given in question .

if we print the element last time then we are going to get the post-order. But for pre-order it does not give us any option from given options, So correct pre-order should be 

Preorder : abejknpofdglcmih

by Boss (45.4k points)
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
50,737 questions
57,312 answers
198,341 comments
105,031 users