mirror of
https://gitlab.uni-marburg.de/langbeid/powersort.git
synced 2025-01-21 19:50:35 +01:00
fix: QuickSort
This commit is contained in:
parent
d06cb9eebd
commit
4528a544b7
@ -127,8 +127,8 @@ public final class DualPivotQuicksort {
|
|||||||
* @param pivotIndex2 the index of pivot2, the second pivot
|
* @param pivotIndex2 the index of pivot2, the second pivot
|
||||||
* @param po the method reference for the fallback implementation
|
* @param po the method reference for the fallback implementation
|
||||||
*/
|
*/
|
||||||
private static <A> int[] partition(A array, int high, int pivotIndex1, int pivotIndex2, PartitionOperation<A> po) {
|
private static <A> int[] partition(A array, int low, int high, int pivotIndex1, int pivotIndex2, PartitionOperation<A> po) {
|
||||||
return po.partition(array, 0, high, pivotIndex1, pivotIndex2);
|
return po.partition(array, low, high, pivotIndex1, pivotIndex2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -279,7 +279,7 @@ public final class DualPivotQuicksort {
|
|||||||
* the pivots. These values are inexpensive approximation
|
* the pivots. These values are inexpensive approximation
|
||||||
* of tertiles. Note, that pivot1 < pivot2.
|
* of tertiles. Note, that pivot1 < pivot2.
|
||||||
*/
|
*/
|
||||||
int[] pivotIndices = partition(a, high, e1, e5, DualPivotQuicksort::partitionDualPivot);
|
int[] pivotIndices = partition(a, low, high, e1, e5, DualPivotQuicksort::partitionDualPivot);
|
||||||
lower = pivotIndices[0];
|
lower = pivotIndices[0];
|
||||||
upper = pivotIndices[1];
|
upper = pivotIndices[1];
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ public final class DualPivotQuicksort {
|
|||||||
* Use the third of the five sorted elements as the pivot.
|
* Use the third of the five sorted elements as the pivot.
|
||||||
* This value is inexpensive approximation of the median.
|
* This value is inexpensive approximation of the median.
|
||||||
*/
|
*/
|
||||||
int[] pivotIndices = partition(a, high, e3, e3, DualPivotQuicksort::partitionSinglePivot);
|
int[] pivotIndices = partition(a, low, high, e3, e3, DualPivotQuicksort::partitionSinglePivot);
|
||||||
lower = pivotIndices[0];
|
lower = pivotIndices[0];
|
||||||
upper = pivotIndices[1];
|
upper = pivotIndices[1];
|
||||||
/*
|
/*
|
||||||
|
@ -37,6 +37,7 @@ public abstract class AbstractSortTest {
|
|||||||
Integer[] array = AscendingRuns.newAscendingRuns(numOfRuns, runLength, decreaseBetweenRuns).getCopy();
|
Integer[] array = AscendingRuns.newAscendingRuns(numOfRuns, runLength, decreaseBetweenRuns).getCopy();
|
||||||
sortAndCheckResult(array);
|
sortAndCheckResult(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@CsvSource({
|
@CsvSource({
|
||||||
"2",
|
"2",
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
package de.uni_marburg.powersort.sort;
|
|
||||||
|
|
||||||
public class DualPivotQuicksort extends AbstractSortTest {
|
|
||||||
DualPivotQuicksort() {
|
|
||||||
sortAlg = SortEnum.DPQS;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,7 @@
|
|||||||
|
package de.uni_marburg.powersort.sort;
|
||||||
|
|
||||||
|
public class DualPivotQuicksortTest extends AbstractSortTest {
|
||||||
|
DualPivotQuicksortTest() {
|
||||||
|
sortAlg = SortEnum.DPQS;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user