GATE CS 2026 Set 2 — Question 49
Go beyond PYQs with Success TrackerAI-powered personalised practice and doubt support. Unlimited practice on eligible plans; AI usage limits apply.MSQ+2 / -0HardBinary Search TreesTreesProgramming & Data StructuresBST Successor & Predecessor
Programming & Data Structures → Trees → Binary Search Trees
Last updated
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?
Correct answer
(A) K cannot have any duplicates; (C) After inserting all keys from K, the height of the BST can increase at most by one
Solution
1.Duplicates in : The keys are chosen from the open intervals . In a BST, the inorder traversal yields a sorted sequence of keys. For any leaf , its successor is the immediate next node in the inorder sequence. Therefore, the intervals for different leaves are disjoint (they represent gaps between adjacent values in the sorted sequence). Since the intervals are disjoint, all selected keys must be distinct. Thus, cannot have duplicates. Statement (A) is true.
2.Size of : If the BST consists of a single root node, it is a leaf (). The root is the maximum element, so its successor is NULL. In this case, no key is inserted, and is empty. Thus, does not necessarily have at least one element. Statement (B) is false.
3.Height Increase: Each key satisfies . Since is a leaf, it has no right child. In a BST, a value greater than a node but less than its successor must be in the right subtree of that node. Since has no right child, will be inserted as the right child of . This adds exactly one level to the depth of each such leaf . The height of the tree (maximum depth) can therefore increase by at most 1. Statement (C) is true.
4.Number of Nodes: We insert at most nodes (one for each leaf with a successor). The total number of nodes in the original tree is . The new total is at most . This is not necessarily double the original number of nodes (e.g., in a skewed tree with nodes and 1 leaf, we add at most 1 node). Statement (D) is false.
Continue learning with Success Tracker
A step still unclear? Work through it with support
Use Success Tracker to ask about the reasoning, then try another GATE CS question to check your understanding.
AI-powered practice· Unlimited practice on eligible plans
- PYQs with solutions
- Attempt available previous-year questions, then compare your reasoning with the worked solution. Coverage varies by stream.
- Practice that adapts
- Choose a topic, work on weaker areas and bookmark questions to revisit. Your attempts feed your progress tracking.
- AI doubt support
- Ask follow-up questions about a step or concept while practising, instead of stopping at the final answer.
Unlimited practice is available on eligible plans. Free practice and AI usage have limits; check the current plan allowances before choosing.
This page stays readable without an account. AI responses can be wrong; check them against the solution and source material.
More questions on Trees
2026 Set 2 Q12The set T represents various traversals over binary tree. The set S represents the order of…2026 Set 2 Q19Consider the following three ANSI-C programs, P1, P2, and P3. P1 [code] P2 [code] **P3**…2026 Set 1 Q23Let be an odd number greater than 100. Consider a binary minheap with elements stored in an…2026 Set 1 Q24Consider a hash table that is initially empty. The hash table is maintained…2026 Set 1 Q27Consider the following C statements: Which of the following options is/are correct? [figure]