In Java Please(Other Java Code does not Work from other question page)-Create an
ID: 3697658 • Letter: I
Question
In Java Please(Other Java Code does not Work from other question page)-Create an integer array of size of 10. Randomly populate the array with integer from 1 to 100 into the array.
Apply Selection Sort to the unsorted array. Create a counter to count the number of iteration needed to complete the sort of of the array. Display the result of the array after the sort, and the counter.
Apply Merge Sort to the unsorted array. Create a counter to count the number of iteration needed to complete the sort of of the array. Display the result of the array after the sort, and the counter.
Explanation / Answer
import java.io.IOException; class Test { public static void main(String[] args) throws IOException { int[] arr1 = getArray(10); System.out.println(" "); doTest(arr1); } public static void doTest(int[] arr){ System.out.println("SelectionSort :"+selectionSort(arr)); System.out.println("MergeSort :"+(new MergeSort()).sort(arr)); } public static int[] getArray(int n){ int[] arr = new int[n]; for(int i=0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.