GateAI
Binary Search Trees

GATE CSE 2026 Set 2 · Q49

MSQ2 marksMedium

Time

Consider a binary search tree (BST) with nn leaf nodes (n>0n > 0). Given any node VV, the key present in the node is denoted as Val(V)Val(V). All the keys present in the given BST are distinct. The keys belong to the set of real numbers. For a node VV, let Suc(V)Suc(V) denote the node that is its inorder successor. If a node VV does not have an inorder successor, then Suc(V)Suc(V) is NULLNULL. As there are no duplicates, if Suc(V)Suc(V) is not NULLNULL, then Val(V)<Val(Suc(V))Val(V) < Val(Suc(V)). Corresponding to every leaf node LiL_i that has a non-NULLNULL Suc(Li)Suc(L_i), a new key kik_i with the following property is to be inserted into the BST. Val(Li)<ki<Val(Suc(Li))Val(L_i) < k_i < Val(Suc(L_i)) Let KK represent the list of all such new keys to be inserted into the BST. Which of the following statements is/are true?

Select all that applyOne or more correct

Pick every correct option

Solution

Step-by-step verified solution

Official 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

Binary Search Trees

Let us analyze each statement based on the properties of a Binary Search Tree (BST):

  1. Option A: Since all keys in the BST are distinct, each leaf node LiL_i has its successor Suc(Li)Suc(L_i) strictly greater than Val(Li)Val(L_i), with no other existing tree keys between Val(Li)Val(L_i) and Val(Suc(Li))Val(Suc(L_i)). Therefore, for two distinct leaf nodes LiL_i and LjL_j with Val(Li)<Val(Lj)Val(L_i) < Val(L_j), the intervals (Val(Li),Val(Suc(Li)))(Val(L_i), Val(Suc(L_i))) and (Val(Lj),Val(Suc(Lj)))(Val(L_j), Val(Suc(L_j))) are completely disjoint. Since each kik_i belongs to its unique open interval, no two elements in KK can be equal. Hence, KK cannot contain any duplicates. (Statement A is true)

  2. Option B: Consider a BST with only 11 node (the root itself), so n=1n = 1. The root is the only leaf node and also the maximum element in the tree, so its inorder successor is NULL. Thus, no leaf node has a non-NULL successor, resulting in KK being empty (∣K∣=0|K| = 0). Hence, KK does not necessarily have at least one element. (Statement B is false)

  3. Option C: For each leaf node LiL_i, any key kik_i satisfying Val(Li)<ki<Val(Suc(Li))Val(L_i) < k_i < Val(Suc(L_i)) will follow the BST insertion path down to LiL_i and will be attached directly as the right child of LiL_i (since LiL_i is a leaf and has no children). Because each inserted key attaches as an immediate child of an existing leaf node, the depth of any leaf increases by at most 11. Consequently, the total height of the BST can increase by at most 11. (Statement C is true)

  4. Option D: If a BST has total nodes N>nN > n, inserting at most nn keys yields at most N+nN + n nodes, which is strictly less than 2N2N. Thus, the number of nodes will not necessarily double. (Statement D is false)

Therefore, the correct options are A and C.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Binary Search Trees previous year question is Q49 of the GATE CSE 2026 Set 2 paper. Find more GATE CSE PYQs on Binary Search Trees in Programming and Data Structures, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

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.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Binary Search Trees in GATE CSE

Binary Search Trees has 21 GATE CSE PYQs across 17 papers from 2011 to 2026. This is the only 2-mark MSQ among them, and it is the only one in GATE CSE 2026 Set 2.

How GATE tests Binary Search Trees

More from GATE CSE 2026 Set 2

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2026 Set 2 · Q49 · MSQ

Consider a binary search tree (BST) with n leaf nodes (n > 0). Given any node V, the key present in the node is denoted as Val(V). All the keys present in the given BST are distinct. The keys belong to the set of real numbers. For a node V, let Suc(V) denote the node that is its inorder successor. If a node V does not have an inorder successor, then Suc(V) is NULL. As there are no duplicates, if Suc(V) is not NULL, then Val(V) < Val(Suc(V)). Corresponding to every leaf node Li that has a non-NULL Suc(Li), a new key ki with the following property is to be inserted into the BST. Val(Li) < ki < Val(Suc(Li)) Let K represent the list of all such new keys to be inserted into the BST. Which of the following statements is/are true?

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.