We are given a set of n distinct elements and an unlabeled binary tree with n nodes. In how many ways can we populate the tree with the given set so that it becomes a binary search tree? (GATE CS 2011)
(A) 0
(B) 1
(C) n!
(D) (1/(n+1)).2nCn
Answer: (B)
Explanation: There is only one way. The minimum value has to go to the leftmost node and the maximum value to the rightmost node. Recursively, we can define for other nodes.
Recommended Posts:
- Data Structures | Binary Search Trees | Question 12
- Data Structures | Binary Search Trees | Question 10
- Data Structures | Binary Search Trees | Question 8
- Data Structures | Binary Search Trees | Question 12
- Data Structures | Binary Search Trees | Question 5
- Data Structures | Binary Search Trees | Question 2
- Data Structures | Binary Search Trees | Question 1
- Data Structures | Binary Search Trees | Question 4
- Data Structures | Binary Search Trees | Question 7
- Data Structures | Binary Search Trees | Question 6
- Data Structures | Binary Search Trees | Question 12
- Data Structures | Balanced Binary Search Trees | Question 4
- Data Structures | Balanced Binary Search Trees | Question 5
- Data Structures | Balanced Binary Search Trees | Question 10
- Data Structures | Balanced Binary Search Trees | Question 13
- Data Structures | Balanced Binary Search Trees | Question 13
- Data Structures | Balanced Binary Search Trees | Question 2
- Data Structures | Balanced Binary Search Trees | Question 12
- Data Structures | Balanced Binary Search Trees | Question 9
- Data Structures | Balanced Binary Search Trees | Question 2

