Próximo SlideShare
Attached below is the prompt of where I need help on- I am wondering h.docx
Cargando en ... 3
1 de 2

### In java- Create an insertion sort algorithm that will accept 100 rando.docx

1. In java, Create an insertion sort algorithm that will accept 100 random values in an array, print the sorted values in the console. Solution Answer: The java code for an insertion sort algorithm that will accept 100 random values in an array is given as below : import java.util.*; class InsertionSortApplication { public static void main(String[] args) { int A[] = new int[10]; allotArray(A); System.out.println("The numbers previously sorting the array is : "); arrayShow(A); InsertionSortApplication(A); System.out.println("The numbers after sorting the array is : "); arrayShow(A); } private static void InsertionSortApplication(int[] arr) { for (int i = 1; i < arr.length; i++) { int readvalue = arr[i]; int j = i; while (j > 0 && arr[j - 1] > readvalue) { arr[j] = arr[j - 1]; j--; } arr[j] = readvalue;
2. } } public static void arrayShow(int[] B) { System.out.println(Arrays.toString(B)); } public static void allotArray(int[] B) { for (int i = 0; i < B.length; i++) { B[i] = (int) (Math.random() * 100); } } }