Skip to content
Related Articles

Related Articles

Data Structures | Binary Search Trees | Question 3
  • Difficulty Level : Hard
  • Last Updated : 08 Feb, 2013
GeeksforGeeks - Summer Carnival Banner

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.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :