-
How many distinct binary search trees can be created out of 4 distinct keys?
-
- 5
- 14
- 24
- 42
- 5
Correct Option: B
The number of keys as per given are 4
Applying the direct formula Bn = 1 / (n + 1) × (2n! / n!n!)
where, Bn is number of binary trees 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 × 6/(4 × 3 × 2)
→ Bn = 56/4
→ Bn = 14
The total number of binary trees with n = 4 is 14.