You are viewing a single comment's thread. Return to all comments →
Java:
public static void insertionSort1(int n, List<Integer> arr) { int key = arr.get(n - 1); int j = n - 2; int[] arr2 = arr.stream().mapToInt(a -> a.intValue()).toArray(); for (; j >=0 && arr2[j] > key; --j) { arr2[j+1] = arr2[j]; for (int k = 0; k < n; k++) { System.out.print(arr2[k] + " "); } System.out.println(); } arr2[j+1] = key; for (int k = 0; k < n; k++) { System.out.print(arr2[k] + " "); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Insertion Sort - Part 1
You are viewing a single comment's thread. Return to all comments →
Java: