Algorithms and Data Structures for Programming Contests

Divide-and-Conquer Algorithms (Cont'd)

Regroup

Runtime satisfies recurrence T(n) = 4 T(n/2) + O(n).
So by Master Theorem, T(n) = O(n2) — no better than iterative algorithm!

Key insight

Resulting algorithm and runtime

How did this happen?

Moral

More Examples

Mergesort

Quicksort and Selection

To learn more...

Back to Algorithms


© Copyright 2012–2015 François Pitt <francois.pitt@utoronto.ca>
last updated at 08:24 (EST) on Thu 5 Mar 2015
Creative Commons License Algorithms and Data Structures by François Pitt is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.