Let be the number of different binary search trees on distinct elements.
Then , where is
View worked solution
Answer: B
To find the number of unique binary search trees (BSTs) that can be constructed with distinct keys, we can choose any element (where ) as the root of the tree.
Once the -th smallest element is chosen as the root:
- The left subtree must contain the elements that are smaller than the root. The number of ways to form this left subtree is .
- The right subtree must contain the remaining elements that are larger than the root. The number of ways to form this right subtree is .
Since the structures of the left and right subtrees are independent, the total number of unique BSTs with the -th element as the root is given by the product:
Summing this product over all possible choices of the root from to gives the total number of BSTs :
Comparing this with the given recurrence relation , we get:
Therefore, the correct option is B.
Free practice · Your answers on this page are not saved.
