3 ms·
Maybe I misunderstand something, but I thought the whole point of selecting two pivots in Quicksort was to reduce impact of particularly bad pivot selection. I
by asgard1024 13y ago
Maybe I misunderstand something, but I thought the whole point of selecting two pivots in Quicksort was to reduce impact of particularly bad pivot selection.
In this case, I don't know.. Unlike in Quicksort, there is no huge cost after selecting the pivot depending on it's value.
I guess it could be useful if you could expect you're searching for items with a different random distributions than are the items in the list, e.g. you search for uniformly distributed elements in a list with non-uniform distribution (like a highly skewed one).
- vkostyukov 13y agoHaving two pivots in Quicksort reduces the number of swaps (# of comparisons is the same).