DATA STRUCTURE
Programming and Technical
Programming
Technical
How many different binary trees and binary search trees
can be made from three nodes that contain the key values
1, 2 & 3?
Read Solution (Total 5)
-
- BST = 2n!/n!(n+1)!
BT = 2n!(n+1)!
given n = 3
so,BST = 6!/3!4! = 5;
and,BT = 6!/4! = 30;
- 10 years agoHelpfull: Yes(6) No(0)
- 1) in Binary Search Tree(BST) their is a order in which every node has left child which is smaller than it and right child which is larger than it. and in case of binary Tree such order is not needed.
YES by using key values 1 , 2 & 3 we can make 5 different BST while using exactly the same key values as node we can make 30 different Binary Tree(as their is no order while arranging the nodes). - 10 years agoHelpfull: Yes(2) No(0)
- Binary tree :- 30 as follows
1 1 2 2 3 3
/ / / / / /
2 3 3 2 1 3 3 1 1 2 2 1
1 1 1 1 1 1 1 1
/ / / /
2 3 2 3 2 3 2 3
/ / / /
3 2 3 2 3 2 3 2
2 2 2 2 2 2 2 2
/ / / /
1 3 1 3 1 3 1 3
/ / / /
3 1 3 1 3 1 3 1
3 3 3 3 3 3 3 3
/ / / /
2 1 2 1 2 1 2 1
/ / / /
1 2 1 2 1 2 1 2
Binary search tree :-5 as follows
1 1 2 3 3
/ / /
2 3 1 3 1 2
/ /
3 2 2 1
- 10 years agoHelpfull: Yes(1) No(2)
- i think,binary tree 12 and binary search tree 4
- 11 years agoHelpfull: Yes(0) No(2)
- countBST(n) = (2n)!/(n+1)!*n!
countBT = countBST(n) * n! - 6 years agoHelpfull: Yes(0) No(0)
DATA STRUCTURE Other Question