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)?

  1. A. Θ(n² log n)
  2. B. Θ(log n)
  3. C. Θ(n log log n)
  4. 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

Exams that ask this topic