Analysis of Merge Sort
Understand the analysis of merge sort by exploring its divide-and-conquer approach that divides arrays, recursively sorts subarrays, and merges them. Learn why merge sort runs in Theta n log n time and how it compares to in-place algorithms in terms of space usage.
We'll cover the following...
Given that the merge function runs in mergeSort() runs in
The divide step takes constant time, regardless of the subarray size. After all, the divide step just computes the midpoint
The conquer step, where we recursively sort two subarrays of approximately
The combine step merges a total of
If we think about the divide and combine steps together, the