Rewriting to use compare() method for comparison counting
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user