Data Structures & AlgorithmsHardProduct-company MCQ pattern

What is the maximum number of comparisons top-down merge sort can make on 8 elements (any input order)?

  1. A. 16
  2. B. 28
  3. C. 17
  4. D. 24

Correct answer: C. 17

In the worst case each merge of sizes m and n takes m + n − 1: 4 × 1 + 2 × 3 + 1 × 7 = 17 = n log₂ n − n + 1 = 24 − 8 + 1. 24 is the rough n log₂ n estimate, and checking all 8! inputs confirms 17.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic