Data Structures & AlgorithmsModerateTCS NQT · Infosys pattern

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

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

Correct answer: A. Θ(n log n)

a = 2, b = 2, so n^(log_b a) = n, which equals f(n) = n: case 2 gives Θ(n log n). This is the merge sort recurrence.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic