Idempotent partition around median of 5?

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Fri Feb 5 16:58:42 PST 2016


On 02/04/2016 03:30 PM, Timon Gehr wrote:
> At most 6 comparisons, <=3 swaps, idempotent (optimal number of swaps):

Timon, Ivan, this is amazing work. I don't know how your minds work 
folks - I sat for like two hours on it yesterday and couldn't crack it.

Surprisingly in a test on millions of random numbers, Ivan's version 
wins by a hair. Might be the tighter code which has icache effects.

Thanks very much! I should say that at these point no better definitions 
can be found on the Net.


Andrei



More information about the Digitalmars-d mailing list