Question: The language is java, make sure to complete everything and that the output is correct: Write a program to 1) Declare an int array of
The language is java, make sure to complete everything and that the output is correct:
Write a program to
1) Declare an int array of 5000 elements
2) Randomly assign distinct numbers between 1 and 5000 into the array
3) Randomly pick a target number between 1 and 5000
4) Write a method to use sequential (linear) search to find the target number and return the actual number of comparisons it takes to find the target number
5) In your main method, call the random target number picking and linear search methods 500 times.
Print out:
1) The smallest number of comparisons
2) The largest number of comparisons
3) The average number of comparisons.
Be sure to follow all the directions, complete everything and send the correct code with correct output as asked
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
