Rewriting to use compare() method for comparison counting

This commit is contained in:
2020-06-01 16:25:20 -05:00
parent c12372b2c0
commit db07554c4c

View File

@@ -11,7 +11,7 @@ public class QuickSorter extends Sorter{
}
private void quickSort(int lowIndex, int highIndex){
if(lowIndex<highIndex){
if(compare(lowIndex,highIndex)<0){
int pivot = partition(lowIndex, highIndex);
quickSort(lowIndex, pivot-1);
quickSort(pivot+1, highIndex);
@@ -22,7 +22,7 @@ public class QuickSorter extends Sorter{
int pivot = numbers[highIndex];
int i = lowIndex-1;
for(int j=lowIndex;j<highIndex;j++){
if(numbers[j]<pivot){
if(compare(numbers[j],pivot)<0){
i++;
swap(i,j);
}