Multiple choice

The following numbers are inserted into an empty binary search tree in the given order: 10, 1, 3, 5, 15, 12, 16. What is the height of the binary search tree (the height is the maximum distance of a leaf node from the root)?

  1. 2

  2. 3

  3. 4

  4. 6

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Inserting 10, 1, 3, 5, 15, 12, 16 into a BST creates a tree where 10 is the root, 1 is the left child, 3 is the right child of 1, 5 is the right child of 3, 15 is the right child of 10, 12 is the left child of 15, and 16 is the right child of 15. The longest path from the root (10) to a leaf (5 or 16) has 3 edges (10-1-3-5).