Merge Sort
Merge Sort is an efficient, stable, divide-and-conquer sorting algorithm. It works by dividing the array into halves, sorting each half, and then merging them back together. The merge operation efficiently combines two sorted arrays into one.
Steps:
- Divide the array into two halves
- Recursively sort each half
- Merge the sorted halves to produce the final sorted array
Time Complexity
Best: O(n log n)
Average: O(n log n)
Worst: O(n log n)
Space Complexity
O(n)
Array length:
7
Speed: