GATE CSE 2026 Session 2 Q49: Inserting a key between each BST leaf and its inorder successor
- Programming and Data Structures
- 2 marks
- MSQ
- No negative marking
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?
Try it: multiple select: one or more correct options
Show answer and explanation
Answer: A, C (official GATE 2026 final answer key)
Concept used: In inorder, the intervals (leaf, successor) for different leaves are disjoint, and each new key becomes the right child of its leaf.
First step: Consider a single-node tree, or a tree whose only leaf holds the maximum key, to test option B; then see where each is inserted.
Full step-by-step solution
Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.
Share this question
Source: official GATE 2026 Session 2 CS question paper and final answer key, organised by IIT Guwahati. Question paper · Answer key
More Programming and Data Structures PYQs
- 2026 Session 1 · Q23Non-leaf indices in a 1-indexed binary heap with n odd
- 2026 Session 1 · Q24Empty slots after linear-probing inserts with h(x) = (x+7) mod 11
- 2026 Session 1 · Q33Maximum height of a full binary tree with 23 nodes
- 2026 Session 1 · Q34Output of a C function with a shadowed block variable
- 2026 Session 1 · Q39Recursive length of a non-empty singly linked list
- 2026 Session 1 · Q40Third insertion that can never yield a complete BST of 1..15