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?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2011 · Q29
Time
Select one answerSingle correct
Solution
Official answer: B) 1
Binary Search TreesIn a Binary Search Tree (BST), an in-order traversal of the tree visits the keys in strictly increasing sorted order.
Since all elements in the given set are distinct, there is exactly one sorted sequence of these elements.
For a given fixed binary tree structure with nodes, the in-order traversal visits the nodes in a uniquely determined order of positions.
To satisfy the binary search tree property, the -th smallest element must be placed at the -th node visited during the in-order traversal for each .
Therefore, there is exactly 1 way to place the elements into the fixed binary tree structure such that it becomes a valid binary search tree.
Hence, the correct option is (B) [p1].
Try the question first, then check your work.
Examiner trap
Recall that the in-order traversal of any valid binary search tree must yield the elements in strictly increasing order.
This Binary Search Trees previous year question is Q29 of the GATE CSE 2011 paper. Find more GATE CSE PYQs on Binary Search Trees in Programming and Data Structures, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Binary Search Trees PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Binary Search Trees has 21 GATE CSE PYQs across 17 papers from 2011 to 2026. 6 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2011.
How GATE tests Binary Search TreesIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.