Data Structures & AlgorithmsVery hardICPC regional · probability
Problem: What is the expected number of distinct values when n balls are thrown uniformly into n bins?
- A. Exactly n
- B. About log n
- C. About n(1 - 1/e)
- D. About n^2
Correct answer: C. About n(1 - 1/e)
The expected number of empty bins is about n/e, so the distinct occupied bins are about n(1 - 1/e).
More Coding Interview Problems questions
- Problem: Which algorithm is the standard way to find the minimum number of swaps to sort a permutation?
- Problem: What is the complexity of binary exponentiation for computing a^b mod m?
- Problem: What property of an array makes the two-pointer technique for pair sums valid?
- Problem: What is the purpose of a 'segment tree beats' structure?
- Problem: What is the number of comparisons needed in the worst case to check whether a sorted array of n elements contains a given value…
- Problem: What is the greedy choice used in the 'minimum number of arrows to burst balloons' problem?