adding linked list version of insertion sort

This commit is contained in:
2020-06-16 13:44:08 -05:00
parent 72895d3cfd
commit 9910ec23b2
3 changed files with 43 additions and 8 deletions

View File

@@ -84,7 +84,7 @@ public class AlgorithmTester{
int input;
boolean ready=false;
boolean print=false;
String[] sortingAlgoNames = {"bubble sort","selection sort","insertion sort","counting sort","quick sort","quick sort (3-way partition)","merge sort"};
String[] sortingAlgoNames = {"bubble sort","selection sort","insertion sort","insertion sort (linked list)","counting sort","quick sort","quick sort (3-way partition)","merge sort"};
boolean[] sortingAlgoChoices = new boolean[sortingAlgoNames.length];
System.out.print("\nPlease enter file name: ");
filename = sc.next();
@@ -133,10 +133,11 @@ public class AlgorithmTester{
boolean bubble=sortingAlgoChoices[0];
boolean selection=sortingAlgoChoices[1];
boolean insertion=sortingAlgoChoices[2];
boolean counting=sortingAlgoChoices[3];
boolean quick=sortingAlgoChoices[4];
boolean quickTWP=sortingAlgoChoices[5];
boolean merge=sortingAlgoChoices[6];
boolean insertionll=sortingAlgoChoices[3];
boolean counting=sortingAlgoChoices[4];
boolean quick=sortingAlgoChoices[5];
boolean quickTWP=sortingAlgoChoices[6];
boolean merge=sortingAlgoChoices[7];
ArrayList<SortResult> results = new ArrayList<SortResult>();
RandomNumberFileReader reader = new RandomNumberFileReader(filename);
if(bubble){
@@ -151,6 +152,10 @@ public class AlgorithmTester{
InsertionSorter inSorter = new InsertionSorter(reader);
results.add(inSorter.measuredSort());
}
if(insertionll){
InsertionSorterLinkedList inSorterLL = new InsertionSorterLinkedList(reader);
results.add(inSorterLL.measuredSort());
}
if(counting){
CountingSorter countSorter = new CountingSorter(reader);
results.add(countSorter.measuredSort());