Data Structures & AlgorithmsHardTCS NQT · data structures

Problem: What is the expected depth of a random binary search tree built from n distinct keys?

  1. A. Θ(log n) on average
  2. B. Θ(n) always
  3. C. Θ(n^2)
  4. D. Θ(1)

Correct answer: A. Θ(log n) on average

Random insertion orders produce balanced-enough trees, so the average depth is logarithmic.

More Coding Interview Problems questions

Exams that ask this topic