add 3-way partition quick sort
This commit is contained in:
@@ -196,7 +196,7 @@ public class AlgorithmTester{
|
|||||||
int input;
|
int input;
|
||||||
boolean ready=false;
|
boolean ready=false;
|
||||||
boolean print=false;
|
boolean print=false;
|
||||||
String[] sortingAlgoNames = {"selection sort", "insertion sort", "quick sort"};
|
String[] sortingAlgoNames = {"selection sort", "insertion sort", "quick sort", "quick sort (3-way partition)"};
|
||||||
boolean[] sortingAlgoChoices = new boolean[sortingAlgoNames.length];
|
boolean[] sortingAlgoChoices = new boolean[sortingAlgoNames.length];
|
||||||
System.out.print("\nPlease enter file name: ");
|
System.out.print("\nPlease enter file name: ");
|
||||||
filename = sc.next();
|
filename = sc.next();
|
||||||
@@ -246,19 +246,24 @@ public class AlgorithmTester{
|
|||||||
boolean selection = sortingAlgoChoices[0];
|
boolean selection = sortingAlgoChoices[0];
|
||||||
boolean insertion = sortingAlgoChoices[1];
|
boolean insertion = sortingAlgoChoices[1];
|
||||||
boolean quick = sortingAlgoChoices[2];
|
boolean quick = sortingAlgoChoices[2];
|
||||||
|
boolean quick3way = sortingAlgoChoices[3];
|
||||||
ArrayList<SortResult> results = new ArrayList<SortResult>();
|
ArrayList<SortResult> results = new ArrayList<SortResult>();
|
||||||
if(selection){
|
if(selection){
|
||||||
WordSelectionSorter selSorter = new WordSelectionSorter(reader);
|
Sorter selSorter = new WordSelectionSorter(reader);
|
||||||
results.add(selSorter.measuredSort());
|
results.add(selSorter.measuredSort());
|
||||||
}
|
}
|
||||||
if(insertion){
|
if(insertion){
|
||||||
WordInsertionSorter inSorter = new WordInsertionSorter(reader);
|
Sorter inSorter = new WordInsertionSorter(reader);
|
||||||
results.add(inSorter.measuredSort());
|
results.add(inSorter.measuredSort());
|
||||||
}
|
}
|
||||||
if(quick){
|
if(quick){
|
||||||
Sorter qSorter = new WordQuickSorter(reader);
|
Sorter qSorter = new WordQuickSorter(reader);
|
||||||
results.add(qSorter.measuredSort());
|
results.add(qSorter.measuredSort());
|
||||||
}
|
}
|
||||||
|
if(quick3way) {
|
||||||
|
Sorter q3Sorter = new WordQuickSorterThreeWay();
|
||||||
|
results.add(q3Sorter.measuredSort());
|
||||||
|
}
|
||||||
for(SortResult e: results){
|
for(SortResult e: results){
|
||||||
if(e!=null){
|
if(e!=null){
|
||||||
if(print){
|
if(print){
|
||||||
|
|||||||
Reference in New Issue
Block a user