Skip to content

Merge sort

ordering

Level 2 of 3

Also called Bottom-up merge sort.

fresh numbers

The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from merge sort's own run on the numbers shown.

choose one

question 1

Merge sort works on 7, 8, 4, 9, 6, 2. What is the row just after its fourth merge?

784962
the answer, and why

the answer is C

Round 1 merges three pairs, giving 7, 8, 4, 9, 2, 6. Merge 4 joins the first two pairs while the last pair waits: 4, 7, 8, 9, 2, 6.

if you chose another

  • That is after merge 3, the end of round 1.
  • That is the end, after merge 5.
  • Round 1 merges the last pair too, so 6, 2 becomes 2, 6.

new numbersthe test page's numbers

question 2

How many comparisons does merge sort make on 6, 6, 6, 6, 6, 6?

666666
the answer, and why

the answer is D

On a tie the left goes first, so each merge compares its whole left run, 3 in round 1, then 2, then 4: 9.

if you chose another

  • That sends the right run first, as back to front.
  • Equal numbers are still compared, to find the tie.
  • That is a dearest row's count, 16 placed less 5 merges.

new numbersthe test page's numbers

question 3

Merge sort works on each of these rows of 1 to 7. On which does it make the most comparisons?

the answer, and why

the answer is A

Merge sort makes 14 comparisons on 1, 6, 2, 5, 4, 3, 7, the most of the four.

if you chose another

  • Merge sort makes 13 comparisons on this row, fewer than 14.
  • Merge sort makes 12 comparisons on this row, fewer than 14.
  • Merge sort makes 13 comparisons on this row, fewer than 14.

new numbersthe test page's numbers