3,674 views
3 votes
3 votes
How many numbers of binary tree can be created with 4 nodes which when traversed in post order gives the sequence D, C, B, A?

1. 14

2. 15

3. 10

4. 16

Please Explain.

Is there any formula?

2 Answers

Best answer
4 votes
4 votes

Here one thing to note :

No of trees with given preorder traversal  =  No of trees with given postorder traversal

                                                                                  =  No of trees with given inorder traversal

                                                                                  = No of BSTs

                                                                                  = No of unlabelled binary trees

                                                                                  =  Catalan Number  [  C(2n,n) / (n+1) ]

Here n  =  4

So substituting  n = 4 in the expression we get :

Number of binary trees with given postorder traversal    =   C(8,4) / 5

                                                                                 =  [ 8 * 7 * 6 * 5 ] / [ 1 * 2 * 3 * 4 * 5 ]

                                                                                 =  14 

selected by
0 votes
0 votes
No. Of trees with given postorder= no.of trees with unlabeled nodes =C(2n,n)/n+1
 For n=4
No.of trees possible=C(8,4)/5
=14

Related questions

1 votes
1 votes
0 answers
1
Nandkishor3939 asked Jan 25, 2019
657 views
I think its answer is 8 .Please ,can any one make it sure for me :)
0 votes
0 votes
1 answer
2
Prince Sindhiya asked Jan 2, 2019
730 views
A full binary tree is a tree in which every node other than the leaves has two children. If there are 600 leaves then total number of leaf nodes are?
2 votes
2 votes
3 answers
3
4 votes
4 votes
2 answers
4
Parth Shah asked Dec 11, 2018
1,433 views
Suppose binary tree has only three nodes A,B and C, and you are given the post order traversal of tree as B-A-C . The exact pre order traversal of the tree is?A)C-A-BB)A-...