(int arr[])
| 4 | |
| 5 | public class InsertionSort { |
| 6 | public static void insertionSort(int arr[]) { |
| 7 | for(int i=1; i<arr.length; i++) { |
| 8 | int curr = arr[i]; |
| 9 | int prev = i-1; |
| 10 | //to find the index where curr is to be inserted |
| 11 | while(prev >= 0 && arr[prev] > curr) { |
| 12 | arr[prev+1] = arr[prev]; |
| 13 | prev--; |
| 14 | } |
| 15 | arr[prev+1] = curr; |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | public static void insertionSortDescending(int arr[]) { |
| 20 | for(int i=1; i<arr.length; i++) { |
nothing calls this directly
no outgoing calls
no test coverage detected