3 ms·
Doesn't a sorted array trigger the worst case in that case? Either ascending or decending. It's one of the reasons not to choose the first element as the pivot,
by TheLoneWolfling 11y ago
Doesn't a sorted array trigger the worst case in that case? Either ascending or decending. It's one of the reasons not to choose the first element as the pivot, iirc.
A much more interesting case is the median-of-three pivot. (Namely, median of first / middle / last elements). You can still do it, however.