Computer Sciences > GATE 2026 SET-1 > Binary Search Tree
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?
A
4
B
2
C
10
D
5

Correct : d

A complete BST with 15 nodes (1 to 15) has a unique structure — root = 8, level-1 nodes = 4 and 12, level-2 nodes = 2, 6, 10, 14, and the 8 leaves at level 3.
The root must always be 8 (inserted first). For the 2nd insertion, only 4 or 12 are valid since they go directly as children of 8 and match the required structure. For the 3rd insertion, the valid choices depend on what was inserted 2nd.
If 8 → 4 → ?, then the 3rd element can be 12 (right child of 8) or 2 (left child of 4). Both keep the structure buildable toward the complete BST.
If 8 → 12 → ?, then the 3rd element can be 4 (left child of 8) or 14 (right child of 12) or 10 (left child of 12).
Now checking option D — inserting 5 as the 3rd element. The only way 5 can be 3rd is after 8 and 4 are inserted. In BST, 5 > 4 so 5 becomes the right child of 4. But in the required complete BST, the right child of 4 must be 6, not 5. With 5 already placed as right child of 4, inserting 6 later would make 6 the right child of 5 (since 6 > 5), not the parent of 5. This permanently breaks the complete BST structure — 6 can never occupy its required position as the right child of 4. So 5 can never be the 3rd element in any valid insertion order that produces the complete BST.
Options A (4), B (2), and C (10) are all achievable as the 3rd element through valid insertion sequences as shown above.
Correct answer: D — 5 can NEVER be the 3rd element ✓

Similar Questions

While inserting the elements 71, 65, 84, 69, 67, 83 in an empty binary search tree (BST) in the sequence shown, the element in the lowest level is
#34 MCQ
What are the worst-case complexities of insertion and deletion of a key in a binary search tree?
#69 MCQ
Let T be a binary search tree with 15 nodes. The minimum and maximum possible heights of T are: Note: The height of a tree with a single node is 0.
#211 MCQ

Related Topics

complete BST insertion order GATE 2026 GATE CS 2026 Set-1 Q46 third element inserted BST never GATE BST 1 to 15 complete binary tree insertion complete binary search tree third element GATE data structures BST GATE 2026 BST root 8 insertion sequence GATE

Unique Visitor Count

Total Unique Visitors

Loading......