arrow
arrow
arrow
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?
Question

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?

A.

4

B.

3

C.

2

D.

1

Correct option is B


We need to construct the Binary Search Tree (BST) by inserting the elements in the given order:
40, 60, 50, 37, 52, 15, 8, 22
Recall the BST rule:
· Smaller value → left subtree
· Greater value → right subtree
Step 1: Construct the BST
Insert 40 first, so it becomes the root.
· 60 > 40 → right of 40
· 50 > 40 but 50 < 60 → left of 60
· 37 < 40 → left of 40
· 52 > 40, < 60, > 50 → right of 50
· 15 < 40, < 37 → left of 37
· 8 < 40, < 37, < 15 → left of 15
· 22 < 40, < 37, > 15 → right of 15
The resulting BST is:

Step 2: Determine the Height
The height of a tree is normally defined as the number of edges on the longest path from the root to a leaf.
The longest paths are:
40 → 37 → 15 → 8
and
40 → 37 → 15 → 22
Each contains 3 edges.
Therefore,
Height = 3
Important Note
If height is counted in terms of number of levels/nodes rather than edges, the answer would be 4 levels. However, in standard data-structures terminology:
Height = number of edges in the longest root-to-leaf path

Free Tests

Free
Must Attempt

Basics of Education: Pedagogy, Andragogy, and Hutagogy

languageIcon English
  • pdpQsnIcon10 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon12 Mins
languageIcon English
Free
Must Attempt

UGC NET Paper 1 Mock Test 1

languageIcon English
  • pdpQsnIcon50 Questions
  • pdpsheetsIcon100 Marks
  • timerIcon60 Mins
languageIcon English
Free
Must Attempt

Basics of Education: Pedagogy, Andragogy, and Hutagogy

languageIcon English
  • pdpQsnIcon10 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon12 Mins
languageIcon English

Similar Questions

test-prime-package

Access ‘UGC NET Computer Science’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
528k+ students have already unlocked exclusive benefits with Test Prime!

Similar Questions

Our Plans
Monthsup-arrow