much implementation, ready for first test

This commit is contained in:
2020-05-30 18:46:10 -05:00
parent 741d29f148
commit c680ec7671
8 changed files with 159 additions and 11 deletions

View File

@@ -2,4 +2,20 @@ package Sorting;
public class SelectionSorter extends Sorter {
//a class to sort an array of numbers using selection sort
public SelectionSorter(String filename){
super("selection", filename);
}
void sort(){
for(int i=0;i<numbers.length-1;i++){
int currentMinIndex = i;
for(int j=i+1;j<numbers.length;j++){
int comp = compare(numbers[currentMinIndex],numbers[j]);
if(comp>0){
currentMinIndex = j;
}
}
swap(numbers[i],numbers[currentMinIndex]);
}
}
}