public static int[] selectionSort(int[] arr){
int len = arr.length;
for (int i = 0 ; i < len ; i++){
int min = arr[i];
for(int j = i + 1 ; j < len ; j++){
if(min > arr[j]){
int temp = arr[j];
arr[j] = min;
min = temp;
arr[i] = min;
}
}
}
return arr;
}
No comments:
Post a Comment