(int arr[])
| 4 | |
| 5 | public class SelectionSort { |
| 6 | public static void selectionSort(int arr[]) { |
| 7 | for(int turn=0; turn<arr.length; turn++) { |
| 8 | int minPos = turn; |
| 9 | for(int j=turn+1; j<arr.length; j++) { |
| 10 | if(arr[minPos] > arr[j]) { |
| 11 | minPos = j; |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | //swap |
| 16 | int temp = arr[turn]; |
| 17 | arr[turn] = arr[minPos]; |
| 18 | arr[minPos] = temp; |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | public static void selectionSortDescending(int arr[]) { |
| 23 | for(int turn=0; turn<arr.length; turn++) { |
nothing calls this directly
no outgoing calls
no test coverage detected