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

@@ -34,7 +34,7 @@ abstract class Sorter {
* @param a the index of the first element
* @param b the index of the second element
*/
void swap(int a, int b){
protected void swap(int a, int b){
int tmp = numbers[a];
numbers[a] = numbers[b];
numbers[b] = tmp;
@@ -47,7 +47,7 @@ abstract class Sorter {
* @param b the second integer to be compared
* @return a negative number if the first integer is smaller than the second, 0 if they are equal, and a positive number if the first integer is greater than the second.
*/
int compare(int a, int b){
protected int compare(int a, int b){
comparisonsUsed++;
return Integer.compare(a,b);
}
@@ -58,7 +58,7 @@ abstract class Sorter {
* @param index the index to be written to
* @param value the value to write
*/
void writeToArray(Integer[] array, int index, int value){
protected void writeToArray(Integer[] array, int index, int value){
array[index]=value;
writesUsed++;
}