question is:-
PRE ORDER :- 1,2,3,4,5,6,7,8,9,10,11,12
POST ORDER :- 3,5,4,2,7,8,6,10,11,12,9,1.
Draw the tree, but in the question they didn't specify it is binary or ternary or something else.
i hope they forget it by mistake.
Just assume is it can be a Binary tree?
Pre oder :- Data, Left, Right ( 1st node should be root )
( first node should be root, next to the root node is should be left node of root, if in post-order it is not in place of 2nd last node )
Post order :- Left, Right, Data
( last node should be root, before the last node it should be right node of root, if in pre-order it is not in place of 2nd node )
Now i conclude that, 9 is right of 1 and 2 is left of 1
PRE ORDER :- 1,${\color{Red} {2,3,4,5,6,7,8}} ,{\color{Green}{9,10,11,12}}$
POST ORDER :- ${\color{Red} {3,5,4,2,7,8,6}},{\color{Green} {10,11,12,9}}$,1.
clearly observe that, the right of root contains 9,10,11,12 ===> leave 9 due to it is fixed at immediate right of root.
so remaining elements are 10,11,12.
what is pre-order of those elements ?
10,11,12
what is the post order of those elements?
10,11,12
Is it possible in Binary Tree? (check all 5 trees which can formed by 3 nodes)
NO
Just assume it can be a Ternary Tree
PRE ORDER :- 1,2,3,4,5,6,7,8,9,10,11,12
POST ORDER :- 3,5,4,2,7,8,6,10,11,12,9,1.
2 is left most and 9 is right most, the childs of 9 is 10,11,12 from left to right.
For clear image https://drive.google.com/open?id=1Q1NO4GFEIOhoDPGXeWactpFsk0OByCY7