ProgrammingHardGATE CS · Campus placements

Merge sort merges two halves with n element comparisons, so T(n) = 2T(n/2) + n and T(1) = 0. What is T(8)?

  1. A. 8
  2. B. 12
  3. C. 24
  4. D. 16

Correct answer: C. 24

T(2) = 2, T(4) = 2*2 + 4 = 8, and T(8) = 2*8 + 8 = 24. There are three levels of n comparisons each.

More C Programming questions

Exams that ask this topic