Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

  1. How many distinct binary search trees can be created out of 4 distinct keys?
    1. 5
    2. 14
    3. 24
    4. 42
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.



Your comments will be displayed only after manual approval.