Analysis

The running time depends a lot on where k ends up. We call this the split.

If k is equal to i or j every time, we get

This is a very bad split.

If k is halfway between i and j, we get

This is a very good split.

In fact, it is possible to show that the running time is O(n2) and $\Omega(n\log n)$; these are the worst and best cases, respectively.


next up previous
Next: Expected Case? Up: PROBLEM WITH QUICKSORT Previous: Partition