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 ; these are the worst and best cases,
respectively.