Merge sort
Merge sort · O(n log n)
Elements Active CompletePlayed 0.0 s · same input
Merge sort
Merge sortOperations0
Comparisons0
Writes0
Each comparison or write counts as 1 operation. Playback time is not execution time.
← Back to six-algorithm comparisonHow it works +
Split the array into halves repeatedly, then merge sorted pieces. Compare the front values from both sides and write back the smaller one each time.
Extra space: O(n); Stable. Each comparison or main-array write counts as 1 operation.