ABSTRACT
Merge Sort is a comparison-based sorting algorithm that uses the Divide and Conquer strategy to achieve a guaranteed time complexity. It relies on the fact that merging two sorted lists is significantly more efficient () than sorting an unsorted one from scratch.
The Strategy
- Divide: Split the unsorted list into two sub-lists of roughly size.
- Recursively Sort: Call
MergeSorton both sub-lists until base cases are reached. - Conquer (Merge): Combine the two sorted sub-lists into one sorted result using the
RMergehelper.

Formal Proof of Correctness
Part 1: The Merge Helper (RMerge)
We prove the helper function using Regular Induction because the total number of elements () decreases by exactly 1 in each recursive call.
Algorithm 57 RMerge
procedure RMerge()
if then
return
if then
return
if then
return RMerge()
else
return RMerge()
- Base Case: If both lists are empty (), it returns an empty list, which is sorted.
- Inductive Hypothesis: Assume
RMergecorrectly merges any two sorted lists with combined size . - Inductive Step: For a combined size , we compare the heads (). The smaller element is prepended to the result of
RMergecalled on the remaining elements. By the hypothesis, the sub-call is correct; thus, the final list is sorted.
Part 2: The Main Algorithm
We prove MergeSort using Strong Induction because each subsequent call halves the input size ().
Algorithm 58 Merge Sort
procedure MergeSort()
if then
return
if then
return
return
- Base Case:
- : Returns an empty list (trivially true).
- : Returns , a trivially sorted list containing all elements.
- Inductive Hypothesis: Assume
MergeSortcorrectly sorts all lists with elements for any , where . - Inductive Step:
- Divide the list of size into two halves of size and .
- By the Strong Inductive Hypothesis, since both halves have size , the recursive calls and return correctly sorted lists.
- By the correctness of
RMerge, results in a sorted list of all elements.
Time Analysis
1. Recurrence Extraction
Let be the runtime of MergeSort on a list of size .
Since , the expression is:
2. Method A: Master Theorem
Comparing to :
- (number of recursive calls)
- (factor by which size is reduced)
- (exponent of non-recursive work )
Comparison: and .
Since , we use Case 2:
3. Method B: Unraveling (Iteration)
We substitute the recurrence into itself to find the pattern:
To reach the base case , we set :
Related Notes
- Fast Multiplication – Another application of D&C.
- Master Theorem – Deep dive into the cases used here.
- Recursive Proofs – General framework for Strong vs. Regular Induction.