Data Structures & AlgorithmsModerateProduct-company MCQ pattern

Using the master theorem, what is the solution of T(n) = 4T(n/2) + n²?

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

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

n^(log₂ 4) = n² equals f(n), which is case 2, so an extra log factor appears: Θ(n² log n). Answering Θ(n²) misses the log that comes from the equal work at every level.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic