Data Structures & AlgorithmsVery hardProduct Company SDE · CP practice
A divide-and-conquer routine satisfies T(n) = 2T(n/2) + n / log n. What is its running time (by the master theorem, extended for polylog terms where needed)?
- A. Θ(n² log n)
- B. Θ(log n)
- C. Θ(n log log n)
- D. Θ(n)
Correct answer: C. Θ(n log log n)
Here n^(log_2 2) compares against f(n) = n / log n; applying the appropriate case of the (possibly extended) master theorem gives Θ(n log log n). A common mistake is to ignore the extra polylog factor that the recursion's log n levels contribute, or to misjudge which of n^(log_b a) and f(n) dominates.
More Coding Interview Problems questions
- Fractional knapsack, capacity 12 (items can be split). Items (weight, value): (5, 7), (6, 11), (7, 7), (4, 15). Using the greedy…
- Fractional knapsack, capacity 12 (items can be split). Items (weight, value): (6, 10), (3, 8), (4, 3), (2, 4), (2, 6). Using the greedy…
- Merging overlapping intervals (sort by start, merge when the next interval's start is ≤ the current merged interval's end — touching…
- What is the length of the longest common subsequence of "EEAEEBB" and "DECDADAC"?
- Using the merge-sort inversion-count technique (count, during each merge step, how many left-half elements are greater than the current…
- Using a min-heap of size k (push each element, pop when size exceeds k, so the heap always holds the k largest seen so far), what is the k…