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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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();}
}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply