CScD-320 Recurrence Example:
MergeSort / Optimal QuickSort Recurrence
Let n be defined as 2k for some k > 0.
For n = 1 (20), there is no expense the array is necessarily in order.
For n > 1, there is an expense of n (the merge step in one case, the partition step in the other), plus the expense of two recursive calls of the sorting algorithm for the size n/2.
As a recurrence, this becomes the following:


Propose (as supported by the table): f(n) = n * log2(n) for n = 2k for k > 0
Basis:
(1) = 0 [recurrence]f
Inductive proof:
Assume validity for f(n/2), prove for f(n)
f(n)
= n + 2 * f(n/2)
Recurrence
= n + 2 * (n/2 * log2(n/2))
Inductive hypothesis
= n + n * ( log2(n) log2(2) )
Simplify; expand log2(n/2)
= n + n * ( log2(n) 1 )
Definition of log2(2)
= n log2(n)
Simplify