Data Structures & AlgorithmsModerateTCS NQT Digital · Product Company SDE

Problem: A height-balanced binary search tree is built over the sorted keys 1, 2, …, 10 by always taking the middle element as the root. What is the height of the tree (number of levels, so a single node has height 1)?

  1. A. 5
  2. B. 3
  3. C. 4
  4. D. 6

Correct answer: C. 4

Choosing the middle key as the root halves each subproblem, giving the minimum possible height. Choosing the first key as root produces a chain of height 10.

More Coding Interview Problems questions

Exams that ask this topic