GateAI
Binary Search Trees

GATE CSE 2026 Set 1 · Q40

MCQ2 marksMedium

Time

Let PP be the set of all integers from 1 to 15. 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?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: D) 5

Binary Search Trees

A complete (and here, perfect) binary search tree containing the 1515 elements {1,2,…,15}\{1, 2, \dots, 15\} has a fixed structure uniquely determined by the BST property:

  • Level 0 (Root): 88

  • Level 1: Left child of 88 is 44; Right child of 88 is 1212

  • Level 2:

    • Children of 44: Left is 22, Right is 66

    • Children of 1212: Left is 1010, Right is 1414

  • Level 3 (Leaves): 1,3,5,7,9,11,13,151, 3, 5, 7, 9, 11, 13, 15

For any node to be inserted in the BST, all of its ancestors must be inserted before it:

  1. The 1st element inserted must be the root, which is 88.

  2. The 2nd element inserted must be one of the direct children of 88, which can be 44 or 1212.

  3. The 3rd element can be:

    • If the 2nd element was 44: the 3rd element can be 1212 (child of 88), 22 (child of 44), or 66 (child of 44).

    • If the 2nd element was 1212: the 3rd element can be 44 (child of 88), 1010 (child of 1212), or 1414 (child of 1212).

Thus, the possible third elements inserted are {2,4,6,10,12,14}\{2, 4, 6, 10, 12, 14\}.

To insert 55, all of its ancestors (88, 44, and 66) must already be present in the tree. This requires at least 33 elements inserted prior to 55, so 55 can at earliest be the 4th4^{\text{th}} element inserted.

Therefore, 55 can never be the third element inserted.

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 Q40 of the GATE CSE 2026 Set 1 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. 6 of them are 2-mark MCQs like this one, and GATE CSE 2026 Set 1 has 2.

How GATE tests Binary Search Trees

More from GATE CSE 2026 Set 1

Share this solution

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

GateAI solution cardGATE CSE 2026 Set 1 · Q40 · MCQ

Let P be the set of all integers from 1 to 15. Consider any order of insertion of the elements of P 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?

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.