Merge sort
Merge sort is an interactive experiment in Algorithms Visualised, a free simulation from StudyFi Lab that runs right in your browser.
Merge sort splits the array in half, sorts each half the same way (recursion) and then merges the two sorted halves: it always takes the smaller of the two front elements. Halving gives log₂ n levels and every level handles all n elements, so the running time is O(n log n) in every case. On a tie it takes the left element, so it is stable.
Try this: Try a reversed and then a nearly sorted array of the same size. The comparisons barely change — the input order hardly matters.
Frequently asked questions
What does the “Merge sort” experiment show?
Merge sort splits the array in half, sorts each half the same way (recursion) and then merges the two sorted halves: it always takes the smaller of the two front elements. Halving gives log₂ n levels and every level handles all n elements, so the running time is O(n log n) in every case. On a tie it takes the left element, so it is stable.
How do I try “Merge sort”?
Try a reversed and then a nearly sorted array of the same size. The comparisons barely change — the input order hardly matters.
Studying for a test?
Upload your notes and StudyFi turns them into flashcards, tests and podcasts.