merge sort time complexity
merge sort time complexity
Blog Article
Merge Sort is a divide-and-conquer algorithm.
-
Best case: O(n log n)
-
Average case: O(n log n)
-
Worst case: O(n log n)
-
Space complexity: O(n)
It divides the array, sorts sub-arrays, and merges them. Merge Sort is stable and works well with large datasets. Its consistent performance makes it preferred in scenarios requiring guaranteed time efficiency.