Data Structures & AlgorithmsHardInfosys · Accenture pattern

Top-down merge sort (split until single elements, then merge) sorts an array of 13 elements. How many times is the merge step called?

  1. A. 13
  2. B. 12
  3. C. 4
  4. D. 26

Correct answer: B. 12

Each merge combines two pieces into one. Starting with 13 single-element pieces and ending with 1, you need exactly 13 − 1 = 12 merges, regardless of how the splits fall. '4' is the recursion depth ⌈log₂ 13⌉, not the number of merges.

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

Exams that ask this topic