ProgrammingModerate

A recurrence T(n) = 2 T(n/2) + n describes which algorithm, with which complexity?

  1. A. Merge sort, with O(n log n) time
  2. B. Binary search, with O(log n) time
  3. C. Bubble sort, with O(n^2) time
  4. D. Linear search, with O(n) time

Correct answer: A. Merge sort, with O(n log n) time

Each level splits the input in half and does linear work, which gives n log n by the master theorem.

More C Programming questions

Exams that ask this topic