SESK: Stuff Everyone Should Know · sesk.info/tech-merge-sort-n-log-n
Merge sort splits a list in half, sorts each half, then merges. What is its running time?
O(n log n): log n levels of splitting, n work to merge at each level.
- O(n log n) ✔
- O(n²)
- O(n)
Why: You can only halve n items about log n times. At every level of halving, merging the sorted pieces back together touches all n items once, so the total is n times log n.
Huh, didn't know that: Merge sort is not in place: the simple version needs extra memory about the size of the list to do its merging.
Merge sort solves every problem the same way: split it in half and let someone smaller deal with it.
Like this card?
References
Answer: O(n log n). You can only halve n items about log n times. At every level of halving, merging the sorted pieces back together touches all n items once, so the total is n times log n.
- MIT 6.006 Introduction to Algorithms, Lecture 3: Sorting ocw.mit.edu/courses/6-006-introduction-to-algorithms-spring-2020/resources/mit6_006s20_lec3
Recursively sort first half and second half ... Merge sorted halves into one sorted list ... Guess T(n) = Θ(n log n)
Checked 2026-10-10.
Think this answer is wrong? Tap "Challenge this answer" on the card in the game and tell us why.
More stuff everyone should know
That's stuff everyone should know.