Worst case for QuickSort - when can it occur?
When analyzing QS, every one always refers to the "almost sorted" worst case. When can such a scenario occur with natural input? The only example I came up with is re-indexing. I think people are confusing Quicksort the partition-based sorting algorithm, and "qsort" the various library implementations. I prefer to see Quicksort the algorithm as having a pluggable pivot selection algorithm, which is quite essential in analyzing its behavior. If the first element is always chosen as the pivot, then an already sorted list is the worst-case. Often there's a high probability that the array is