Divide-and-Conquer Algorithms
To solve a problem of size :
- Divide: the problem into subproblems, each of size < :
- Conquer: Solve each subproblem recursively (and independently of the other subproblems).
- Combine/Merge the solutions to the subproblems into a solution to the original problem.
Merge Sort
To sort numbers:
- If : do nothing.
- If : divide the numbers arbitrarily into two sequences, both of size , run Merge sort twice, once for each sequence. Then merge the two sorted sequences into one sorted sequence.
In general, if we do not assume anything about the value of , we find
So the running time of Merge Sort is if is a power of two.