adding merge sort
This commit is contained in:
@@ -84,7 +84,7 @@ public class AlgorithmTester{
|
||||
//boolean quick=false, counting=false, radix=false, merge=false;
|
||||
boolean ready=false;
|
||||
boolean print=false;
|
||||
String[] sortingAlgoNames = {"bubble","selection","insertion","counting","quick"};
|
||||
String[] sortingAlgoNames = {"bubble","selection","insertion","counting","quick","merge"};
|
||||
boolean[] sortingAlgoChoices = new boolean[sortingAlgoNames.length];
|
||||
System.out.print("\nPlease enter file name: ");
|
||||
filename = sc.next();
|
||||
@@ -135,6 +135,7 @@ public class AlgorithmTester{
|
||||
boolean insertion=sortingAlgoChoices[2];
|
||||
boolean counting=sortingAlgoChoices[3];
|
||||
boolean quick=sortingAlgoChoices[4];
|
||||
boolean merge=sortingAlgoChoices[5];
|
||||
ArrayList<SortResult> results = new ArrayList<SortResult>();
|
||||
|
||||
if(bubble){
|
||||
@@ -157,6 +158,10 @@ public class AlgorithmTester{
|
||||
QuickSorter qSorter = new QuickSorter(filename);
|
||||
results.add(qSorter.measuredSort());
|
||||
}
|
||||
if(merge){
|
||||
MergeSorter mSorter = new MergeSorter(filename);
|
||||
results.add(mSorter.measuredSort());
|
||||
}
|
||||
for(SortResult e: results){
|
||||
if(print){
|
||||
for(int i: e.getSortedArray()){
|
||||
|
||||
Reference in New Issue
Block a user