ProgrammingHard

Sorting 2 x 10^6 structs with qsort in C takes about how many comparisons?

  1. A. About 2 x 10^6
  2. B. About 4 x 10^7
  3. C. About 4 x 10^12
  4. D. About 2 x 10^9

Correct answer: B. About 4 x 10^7

n log2 n with n = 2 x 10^6 is about 2 x 10^6 x 21 = 4.2 x 10^7 comparisons, well within a typical limit.

More C Programming questions

Exams that ask this topic