| 1 | public class Main { |
| 2 | static void insertionSort(int[] a){ |
| 3 | int n = a.length; |
| 4 | for(int i = 1; i < n; i++){ |
| 5 | int j = i; |
| 6 | while(j > 0 && a[j] < a[j-1]){ |
| 7 | int temp = a[j]; |
| 8 | a[j] = a[j-1]; |
| 9 | a[j-1] = temp; |
| 10 | j--; |
| 11 | } |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | public static void main(String[] args) { |
| 16 | int[] a = {8, 3, 6, 5, 4, 2}; |
| 17 | insertionSort(a); |
| 18 | for(int val : a){ |
| 19 | System.out.print(val + " "); |
| 20 | } |
| 21 | } |
| 22 | } |
nothing calls this directly
no outgoing calls
no test coverage detected