Idempotent partition around median of 5?
tn via Digitalmars-d
digitalmars-d at puremagic.com
Sat Feb 6 01:50:37 PST 2016
On Saturday, 6 February 2016 at 01:46:58 UTC, Andrei Alexandrescu
wrote:
> On 02/04/2016 03:30 PM, Timon Gehr wrote:
>> At most 6 comparisons, <=3 swaps, idempotent (optimal number
>> of swaps):
>
> Oh, also: could you let that bad boy run and let it find
> anything that does idempotent partition in 6 compares and 0-7
> swaps? Then slowly tighten the number of swaps until you find
> the best balance between number of swaps and code size. --
> Andrei
That is kind of what I tried to do by hand. My function
partition5e seems to be practically identical to Ivans solution
and partition5a is just a copy of Timons solution. Function
partition5b, partition5c and partition5d are in between of those
with various tradeoffs between the number of swaps and code size.
More information about the Digitalmars-d
mailing list