Question

Let PP be the set of all integers from 11 to 1515. Consider any order of insertion of the elements of PP into a binary search tree that creates a complete binary tree.

Which one of the following elements can NEVER be the third element that is inserted?

Choose one option
Official answer and solution
Official answer
D
From
Official GATE 2026 answer key

Solution

Construct the unique complete BST on {1,…,15}\{1, \dots, 15\} and use the property that no node can be inserted into a BST before its parent.

A complete binary tree with 15=24−115 = 2^4 - 1 nodes is a perfect binary tree of height 33. Since the inorder traversal of the BST must be 1,2,…,151, 2, \dots, 15, the unique BST structure has:

  • Depth 0 (root): 88
  • Depth 1: 44 (left child of 88) and 1212 (right child of 88)
  • Depth 2: 2,62, 6 (children of 44) and 10,1410, 14 (children of 1212)
  • Depth 3 (leaves): 1,3,5,7,9,11,13,151, 3, 5, 7, 9, 11, 13, 15

In any valid BST insertion order that produces this tree, every node must be inserted after all of its ancestors:

  • The 1st element inserted must be the root 88.
  • The 2nd element inserted must be at depth 1 (44 or 1212).
  • The 3rd element inserted can only be at depth 1 or depth 2 (namely 4,12,2,6,10,4, 12, 2, 6, 10, or 1414).
  • Since 55 is at depth 3 (its ancestors are 8→4→6→58 \rightarrow 4 \rightarrow 6 \rightarrow 5), all three ancestors 8,4,68, 4, 6 must be inserted before 55, so 55 can be at earliest the fourth element inserted.
Final answer

Option (D)

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 1 (CS1)
Question
40 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.