import java.util.*; public class InsertionSort1 { public static void main (String[] argv) { int[] testData = {51, 24, 63, 73, 42, 85, 71, 41, 87, 32}; System.out.println ("Before: " + Arrays.toString(testData)); int[] sortedData = insertionSort (testData); System.out.println ("After: " + Arrays.toString(sortedData)); } static int[] insertionSort (int[] A) { int[] B = new int [A.length]; for (int i=0; iposInB; j--) { // We need this because the array has to be shifted except // for the last position when i=n-1. if (j < B.length) { B[j] = B[j-1]; } } // Assign A[i] in right place. B[posInB] = A[i]; } return B; } static int[] makeRandomArray (int length) { int[] A = new int [length]; for (int i=0; i