/* Recursion with zssort_rand ensures logn+1 stack spacen need! */
zssort_rand(array,low,pi-1,state);
zssort_rand(array,pi+1,high,state);
}
}
}
// TODO: Idea: Quadratic time happens when you repeatedly pick pivots close to the maximum or minimum - so why not re-pick near extremals being picked which now can be cheked? I think we should have a treshold - maybe dynamically set by first minmax - and logarithmically divide the treshold by 2 in case its still too close the next randomization time. This handles smallrange badly though.
// TODO: Guess the pivot value by previous min-maxes and let us use it inn partitioning (which would lead to "closest to pivot value" being swapped to its right position to keep the left:pivot:right separation architecture. Maybe can be faster than rand, although our randoms are pretty darn fast as you can see.
// TODO: Hackzolt éjféli ötlet:
// - Particionálás min-max-avgleft-el
// - két irányba rekurzió, bal oldalinak avgleft átadása, másik sima zssort_rand
// - avgleft-es rekurzióból visszahívás ennek a jelenleginek a fő függvényére (ide-oda típusú rekurzió!)
// - esetleg ha megéri, akkor avgright kiszámítása is jó lehet: drágább műveletek, de jobb algoritmus... hmmm