Data Structures & AlgorithmsHardAmazon · Microsoft OA

A divide-and-conquer routine satisfies T(n) = 4T(n/2) + n² log n. What is its running time?

  1. A. Θ(n² log n)
  2. B. Θ(n³)
  3. C. Θ(n² log log n)
  4. D. Θ(n² log² n)

Correct answer: D. Θ(n² log² n)

Here n^(log₂4) = n², and f(n) = n² log n is n² times log¹ n, so the extended master theorem (case 2 with k = 1) gives Θ(n² log^(k+1) n) = Θ(n² log² n). Θ(n² log n) forgets the extra log factor that comes from the log n levels of the recursion.

More Coding Interview Problems questions

Exams that ask this topic