GATE / CS ARCHIVE

GATE CSE 1996 / QUESTION 2.14

Sizes of root subtrees after BST insertion

Data Structures · Binary Search & Balanced Trees · Full GATE CSE 1996 paper

GATE 1996, Q2.14 2 marks · MCQ
Report issue

Binary Search & Balanced Trees

Question 2.14, GATE 1996: Insert 50,15,62,5,20,58,91,3,8,37,60,24 into an empty BST. Count nodes in the left and right subtrees of the root.
Tap to enlarge
Your answer
Answer & solution

Answer: B: 7 and 4 (no official key was published)

Step through it (14 steps)

The first key 50 remains the root in ordinary unbalanced BST insertion. Every later key below 50 belongs somewhere in its left subtree: 15,5,20,3,8,37,24, totaling seven. Every key above 50 belongs in its right subtree: 62,58,91,60, totaling four. Internal insertion paths affect shape but not which side of the root contains each key. The root itself is excluded from both counts, and 7+4+1=12 checks the total number of inserted keys.

Original paper, page 5