Question
Consider a binary search tree (BST) with leaf nodes (). Given any node , the key present in the node is denoted as . All the keys present in the given BST are distinct. The keys belong to the set of real numbers.
For a node , let denote the node that is its inorder successor. If a node does not have an inorder successor, then is . As there are no duplicates, if is not , then .
Corresponding to every leaf node that has a non-NULL , a new key with the following property is to be inserted into the BST.
Let represent the list of all such new keys to be inserted into the BST. Which of the following statements is/are true?
Official answer and solution
- Official answer
- A and C
- From
- Official GATE 2026 answer key
Solution
Analyze the open intervals for distinct leaves and determine where each new key gets attached in the BST.
Let us check each statement:
- (A) is true: For any two distinct nodes and with , since is the smallest key in the BST strictly greater than , we have . Hence the open intervals are pairwise disjoint, so no two can be equal.
- (B) is false: If the BST has only 1 node (or is a left-skewed chain where the single leaf is the maximum element in the tree), that leaf has , so is empty.
- (C) is true: Because is a leaf and , no existing key in the BST lies between and , and has no children. When is inserted into the BST, the search path must reach and attach as the right child of . Since at most one key is generated per leaf , each existing leaf receives at most one right child, so the height of the BST increases by at most .
- (D) is false: At most keys are inserted (where is the number of leaves), which is strictly less than the total number of nodes in any BST with node.
Options (A), (C)
Assuming must be non-empty without testing a 1-node BST or a right-skewed/left-skewed chain whose single leaf is the maximum element.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2026 Computer Science and Information Technology - Session 2 (CS2)
- Question
- 49 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.