Idempotent partition around median of 5?

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sat Feb 6 05:00:11 PST 2016


On 02/05/2016 08:58 PM, Timon Gehr wrote:
> On 02/06/2016 02:39 AM, Andrei Alexandrescu wrote:
>> On 02/04/2016 03:30 PM, Timon Gehr wrote:
>>> At most 6 comparisons, <=3 swaps, idempotent (optimal number of swaps):
>>
>> What is the minimum number of comparisons? Thx! -- Andrei
>
> There is no partition algorithm that uses <= 5 comparisons in all cases.
> (If that is what you're asking.)

Was asking about this particular one. For example, the maximum 
comparisons is 6, but it would be good to know the average number of 
comparisons. I know I could read through the code, but it's hairy. 
Thanks! -- Andrei



More information about the Digitalmars-d mailing list