Distinct keys can create primary keys - Algorithms

Q.  Out of 4 distinct keys how many distinct primary keys can be created?
- Published on 16 Jun 15

a. 5
b. 20
c. 45
d. 14

ANSWER: 14
 
the no of keys given are 4
apply the formula Bn=1/(n+1)*(2n!/n!n!)
where B is the binary tree and n is the number of keys.
Bn=1/(4+1)*(8!/4!4!)
Bn=1/5*(8*7*6*5*4!)/4!4!
Bn=8*7*9*6/(4*3*2)
Bn=56/4
Bn=14
Hence, the total no of binary trees with n=4 is 14.

Post your comment / Share knowledge


Enter the code shown above:
 
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)