GATE / CS ARCHIVE

GATE CSE 2004 / QUESTION 4

Height after binary-search-tree insertions

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

GATE 2004, Q4 1 mark · MCQ
Report issue

Binary Search & Balanced Trees

Question 4, GATE 2004: Insert 10,1,3,5,15,12,16, in that order, into an empty binary search tree. What is its height, defined as the maximum edge distance from root to a leaf?
Options:
(A) 2
(B) 3
(C) 4
(D) 6
Question 4, GATE 2004: Insert 10,1,3,5,15,12,16, in that order, into an empty binary search tree. What is its height, defined as the maximum edge distance from root to a leaf?
Options:
(A) 2
(B) 3
(C) 4
(D) 6
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step through it (9 steps)

1. Inserting10,1,3,5 produces the chain 10→1→3→5 on the left side. The remaining 15,12,16 form a right subtree rooted 15 with two children.

2. The deepest leaf 5 is three edges from 10, so the stated edge-distance height is 3, B.

3. Teaching check: The complete parent-child structure is 10:(left 1,right 15), 1:(right 3), 3:(right 5), 15:(left 12,right 16). The deepest path has four vertices but three edges. Distinguishing edge height from node count eliminates the off-by-one distractor.

Original paper, page 1