Idempotent partition around median of 5?

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sat Feb 6 13:57:04 PST 2016


On 02/06/2016 01:42 PM, tn wrote:
> On Saturday, 6 February 2016 at 13:06:37 UTC, Andrei Alexandrescu wrote:
>> Could you please add two simple calculations? Assuming uniform random
>> distribution of data, compute the average number of swaps as a
>> weighted average of orderings. Also, show the number of lines (one
>> test or one swap per line) as a proxy for generated code size. That
>> should provide good insights.
>
> This now prints the numbers of comparison and swap lines and computes
> the average numbers of swaps. In addition, it also runs the same tests
> for permutations of 5 elements some of which might be equal (an example
> of such permutation would be [1, 2, 0, 2, 3], on the other hand [1, 2,
> 0, 2, 4] should not be included since it is identical). However, in this
> case the average number of swaps is perhaps not so meaningful.
>
> http://dpaste.dzfl.pl/2012caf872ec

Awesome, thanks. Will need to try at least a few of these out. At a 
quick glance, partition5d seems to be the sweet spot - it's small and 
does only 3.13/2.57 swaps on average. -- Andrei



More information about the Digitalmars-d mailing list