Merge Sort

Divide and conquer: recursively split, sort, and merge arrays for guaranteed O(n log n) performance

Size:
Speed:
Unsorted
Comparing
Merging
Sorted

About Merge Sort

Time Complexity:

  • Best: O(n log n)
  • Average: O(n log n)
  • Worst: O(n log n)

Space Complexity: O(n)

Stable: Yes

How It Works

Merge Sort uses a divide-and-conquer strategy: it recursively splits the array into smaller subarrays until each contains a single element.

Then it merges these sorted subarrays back together, comparing elements and placing them in the correct order, until the entire array is sorted.

💡 Tip: Merge Sort guarantees O(n log n) time complexity in all cases, making it ideal for large datasets!