Idempotent partition around median of 5?
Xinok via Digitalmars-d
digitalmars-d at puremagic.com
Thu Feb 4 17:39:37 PST 2016
On Thursday, 4 February 2016 at 20:30:57 UTC, Timon Gehr wrote:
> At most 6 comparisons, <=3 swaps, idempotent (optimal number of
> swaps):
>
> void partition5(ref int[5] a){
> if(a[0]<a[1]){
> ...
Great, we can all go home!
I was curious so I did a crude measurement: when compiled for
64-bit with all optimizations turned on (-release -O -inline
-boundscheck=off), the machine code for this function is about
3KB in size.
More information about the Digitalmars-d
mailing list