Data Structures & AlgorithmsHardTCS NQT · data structures
Problem: What is the expected depth of a random binary search tree built from n distinct keys?
- A. Θ(log n) on average
- B. Θ(n) always
- C. Θ(n^2)
- 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
- Problem: What is the Hamming distance between 1011 and 1101 in binary?
- Problem: Which property must a graph have for Euler's theorem to guarantee an Euler circuit?
- Problem: What is the complexity of computing the number of distinct paths in a DAG with V vertices and E edges by DP?
- Problem: How many 4-digit numbers (from 1000 to 9999) are palindromes? Run the code. python print(sum(1 for x in range(1000, 10000) if…
- Problem: What is the time complexity of building a suffix tree of a string of length n over a fixed alphabet with Ukkonen's online…
- Problem: A 3×4 grid has walls '#' at (0,2), (1,1), (2,3). Moves go up, down, left and right through open cells. Starting from (0,0), how…