I need a program that: 1.I need to create a 1 dimensional Array with 31 integers
ID: 3639216 • Letter: I
Question
I need a program that:1.I need to create a 1 dimensional Array with 31 integers by using a random number generator, and then output it
2. With the program I need to use sequential search and locate several target values: some or none in the array. Count the number of iterations it takes to locate each target value and the elapsed time of the search process. Then output it
An example given:
long startTime = System.nanoTime();
//the operation to be measured
long endTime = System.nanoTime() – startTIme;
3. Then use selection sort to order the random integers in ascending order, Log the elapsed time to sort the process
4. Use binary search to search each item in the array. Log the number of iterations and elapsed time before each target value is located. Design your output so that the findings are presented in 3 columns: the sorted array, the corresponding number of iterations to locate this calue, and the corresponding elaspsed time.
Then search for a few numbers that are not in your sorted array and reported the number of iterations and elapsed time.
Explanation / Answer
Here's the core of the program. You should be able to do the rest. ********************************* import java.util.Random; public class Test { public static void main(String args[]) { int arr[] = new int[31]; Random gen = new Random(); for(int i=0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.