Let T(n) be the number of different binary search trees on n distinct elements.

Then , where x is

**(A)** n-k+1

**(B)** n-k

**(C)** n-k-1

**(D)** n-k-2

**Answer:** **(B)** **Explanation:** The idea is to make a key root, put (k-1) keys in one subtree and remaining n-k keys in other subtree.

A Binary Search Tree (BST) is a tree in which all the nodes follow the below-mentioned properties −

- The left sub-tree of a node has a key less than or equal to its parent node’s key.
- The right sub-tree of a node has a key greater than to its parent node’s key.

Now construction binary search trees from n distinct number-

Lets for simplicity consider n distinct numbers as first n natural numbers (starting from 1)

__If n=1 __ We have only one possibility, therefore only 1 BST.

__If n=2 __We have 2 possibilities , when smaller number is root and bigger number is the right child or second when the bigger number is root and smaller number as left child.

__If n=3 __We have 5 possibilities. Keeping each number first as root and then arranging the remaining 2 numbers as in case of n=2.

__If n=4 __We have 14 possibilities. Taking each number as root and arranging smaal numbers as left subtree and larger numbers as right subtree.

Thus we can conclude that with n distinct numbers, if we take ‘k’ as root then all the numbers smaller than k will left subtree and numbers larger than k will be right subtree where the the right subtree and left subtree will again be constructed recursively like the root.

Therefore,

This solution is contributed by **Parul Sharma.**

Quiz of this Question

## Recommended Posts:

- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 1
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 5
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 2
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 3
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 4
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 6
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 7
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 8
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 9
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 10
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 11
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 12
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 13
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 14
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 36
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 37
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 38
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 40
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 41
- GATE | Sudo GATE 2020 Mock III (24 January 2019) | Question 42