Commit 0b4570b3 authored by PIACIBELLO Cyrille's avatar PIACIBELLO Cyrille

Old bug on QuickSort

parent e282ccdf
......@@ -76,6 +76,32 @@ protected:
return left;
}
/* A local iteration of qs */
static void QsLocal(SortType array[], const CompareType& pivot,
IndexType myLeft, IndexType myRight,
IndexType& prefix, IndexType& sufix){
IndexType leftIter = myLeft;
IndexType rightIter = myRight;
while(true){
while(CompareType(array[leftIter]) <= pivot && leftIter < rightIter){
++leftIter;
}
while(leftIter <= rightIter && pivot < CompareType(array[rightIter])){
--rightIter;
}
if(rightIter < leftIter) break;
Swap(array[leftIter],array[rightIter]);
++leftIter;
--rightIter;
}
prefix = leftIter - myLeft;
sufix = myRight - myLeft - prefix + 1;
}
/* The sequential qs */
static void QsSequentialStep(SortType array[], const IndexType left, const IndexType right){
if(left < right){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment