Merge branch 'main' of
https://gitty.informatik.hs-mannheim.de/3024753/PR2-Hummel-3024753.git into mainmain
parent
57d9834299
commit
2906cd48f6
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
public class InsertionSort {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
public class SelectionSort {
|
||||
|
||||
public static int[] selectionSort(int[] arr) {
|
||||
int tmp;
|
||||
int index = 0;
|
||||
|
||||
for(int i=0; i < arr.length; i++) {
|
||||
tmp = arr[i];
|
||||
for(int j = 0; j < arr.length; j++) {
|
||||
if(arr[j] < tmp) tmp = arr[j];
|
||||
index = j;
|
||||
}
|
||||
arr[index] = arr[i];
|
||||
arr[i]=tmp;
|
||||
|
||||
}
|
||||
|
||||
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue