Skip to content
Snippets Groups Projects
Commit 92481c5c authored by Ballabriga Clément's avatar Ballabriga Clément
Browse files

fix quicksort error

parent 10a9571f
No related branches found
No related tags found
No related merge requests found
......@@ -38,8 +38,8 @@ void quicksort(A& array, const C& c = Comparator<typename A::t>()) {
if(L < R) {
piv = array[L];
while(L < R) {
while(c.doCompare(array[R], piv) >= 0 && L < R) R--; if(L < R) array[L++] = array[R];
while(c.doCompare(array[L], piv) <= 0 && L<R) L++; if (L < R) array[R--] = array[L];
while(c.compare(array[R], piv) >= 0 && L < R) R--; if(L < R) array[L++] = array[R];
while(c.compare(array[L], piv) <= 0 && L<R) L++; if (L < R) array[R--] = array[L];
}
array[L] = piv; beg[i+1] = L+1; end[i+1] = end[i]; end[i++] = L;
if(end[i] - beg[i] > end[i-1] - beg[i-1]) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment