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