Skip to content
Minute Campus.

Algorithms you can seeLesson 011 min

How does merge sort split a list and join it back?

Merge sort cuts a list in half, again and again, until every piece holds one number, which is already in order. Then the pieces are joined back in pairs. Each join looks at the front item of both sides and takes the smaller one, so the output stays in order. For the seven-number example the program makes thirteen comparisons.

Remember

Split until each piece is trivial, then merge the pieces in order.

Sources

Checked at the source.

Every claim in the lesson was checked against these before it was recorded.

  1. 1Mergesort, Algorithms 4th edition, section 2.2Sedgewick and Wayne · read 14 Nov 2026Mergesort divides the array into halves, sorts them recursively, and guarantees time proportional to N log N.

Transcript

The lesson, word for word.

Read it at your own pace, or search the page for a term.

How does merge sort split a list and join it back? It cuts the list in half, again and again, until every piece holds one number. One number on its own is already in order. Then the pieces are joined back in pairs. Each join looks at the front item of both sides and takes the smaller one, so the output stays in order. Take a list of seven numbers: thirty-eight, twenty-seven, forty-three, three, nine, eighty-two and ten. The program makes thirteen comparisons while it joins them. It ends with three, nine, ten, twenty-seven, thirty-eight, forty-three and eighty-two, the same seven numbers in order. Merge sort takes a time that grows with the length of the list times its logarithm, which is why it stays fast on long lists. The rule: split until each piece is trivial, then merge the pieces in order.

Questions? Comment on the lesson on YouTube

New lessons every day.

Follow Minute Campus where you already scroll.