Page 1 of 1

DO NOT copy and paste the answer from a similar question on here! I will give you a thumbs down!!! Modify my code. Despe

Posted: Sun Jul 03, 2022 12:00 pm
by answerhappygod
DO NOT copy and paste the answer from asimilar question on here! I will give you a thumbs down!!!Modify my code. Desperately need help finishing this. Javaprogram should randomly generate data to pass to the sortingmethods. The purpose is to write the code to perform thebenchmarking of the algorithm using insertion sort. The programmust include an iterative and a recursive version. In case thearray is not sorted, an exception should be thrown usingNotSortedException.
Code I have so far:
import java.util.Arrays;import java.util.Collection;import java.util.HashSet;import java.util.List;import java.util.LinkedList;import java.util.Random;import java.util.Set;
public class InsertRandomElements
{
public static void main(String[] args)
{
Random r = new Random();int[] random = new int[50];
for (int i = 0; i < random.length; i++){random = r.nextInt(100) + 1;}
for (int i = 0; i < random.length; i++){System.out.println(random);}
List<int[]> randomList = Arrays.asList(random)
sortElements(randomList);
}
private static void sortElements(Collection<int[]>values)
{
Set<int[]> set = new HashSet<int[]>(values);
for (int[] is : set) {System.out.printf("Sorted Elements: %d ", values);}
System.out.println();}
}