closed by
4,432 views
0 votes
0 votes
closed with the note: answer already given

Given preorder and postorder traversal of binary search tree.
Preorder: 50, 27, 16, 4, 12, 34, 29, 44, 88, 65, 52, 77, 93, 92
Postorder: 12, 4, 16, 29, 44, 34, 27, 52, 77, 65, 92, 93, 88, 50
The number of nodes present at level 3 are _________. Assume root is present at level 0.

closed by

3 Answers

Best answer
1 votes
1 votes

Refer this: http://www.geeksforgeeks.org/full-and-complete-binary-tree-from-given-preorder-and-postorder-traversals/

Try this:

Preorder: 50, 27, 16, 4, 12, 34, 29, 44, 88, 65, 52, 77, 93, 92
Postorder: 12, 4, 16, 29, 44, 34, 27, 52, 77, 65, 92, 93, 88, 50

Inorder: 4,12,16,27,29,34,44,50,52,65,77,88,92,93

now from preorder and inorder try to construct a tree.

50 - root

{4,12,16,27,29,34,44} - left subtree of root

{52,65,77,88,92,93} - right subtree of root and do it recursively you contruct a tree.

selected by
0 votes
0 votes
Answer will be 6

level 3 nodes will be 4,29,44,52,77,92
0 votes
0 votes

50,27,16,4,12,34,29,44,88,65,52,77,93,92   preorder

12,4,16,29,44,34,27,52,77,65,92,93,88.85   postorder

make some order two or three element witch occoure alternative .Witch is 

leaf sub group of tree. and witch give idia about what is tree structure. 

      16                                  34                                              65                                                             93                OR                            93                      

4                                    29          44                           52                     77                                        92                                                                     92

       12

THEN COMBINE SOME TREE INTO GROUP THROUGH  POSTORDER

12,4,16,29,44,34,27                                                                                                   27 

--------------------------                 make tree                                                  16                               34

                                                                                                              4                                  29        44

                                                                                                                     12

AND  SO FINAL TREE 

                                                                                                   

                                                                                                                                               50                                                                    level - 0

                                                                                                                           27                                                     88                               level-1

                                                                                                          16                            34                              65                93                    level-2

                                                                                             4                                    29            44                 52      77                  92             level-3

                                                                                                         12                                                                                                             level-4

                                 

Related questions

0 votes
0 votes
0 answers
2
rahul sharma 5 asked Dec 19, 2016
351 views
I am getting 6 as the answer,but correct answer given is 5.Plese correct.