All mock tests are FREE till 31 December — register to save your progress
Unit 7 · Data Structures and Algorithms Paper 2 CS · 22 June 2026

What is the height of the binary search tree obtained by inserting the numbers 40, 60, 50, 37, 52, 15, 8, 22 in the given order

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: B. 3

Explanation

Inserting in order builds the BST as follows: 40 becomes the root; 60 goes to 40's right; 50 (less than 60) goes to 60's left; 37 (less than 40) goes to 40's left; 52 (between 50 and 60) goes to 50's right; 15 (less than 37) goes to 37's left; 8 (less than 15) goes to 15's left; and 22 (between 15 and 37) goes to 15's right. The longest root-to-leaf paths, 40→37→15→8, 40→37→15→22 and 40→60→50→52, each contain 3 edges. Counting height as the number of edges on the longest root-to-leaf path, the height of this BST is 3.

More Data Structures and Algorithms questions