Quicksort Variants
"Nordlöw" via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jul 8 13:50:00 PDT 2014
After having read
http://togototo.wordpress.com/2014/06/20/the-magic-forest-problem-revisited-rehabilitating-java-with-the-aid-of-d/
I stared at
forest_t[] quickSort(forest_t[] fors) pure nothrow {
if (fors.length >= 2) {
auto parts = partition3!(forLessThan)(fors, fors[$ / 2]);
parts[0].quickSort;
parts[2].quickSort;
}
return fors;
}
for a while. Could somebody explain why this gave such a speed
boost? To my knowledge it is an optimization which gives extra
speedup when fors is already partially sorted right?
Are there any plans to merge this optimization into existing or
new sorting algorithms in Phobos?
I recall that Python's default sorting algorithm is related to
this, right?
More information about the Digitalmars-d-learn
mailing list