Question: In Dr Java! Need help ASAP! Linear Search Vs Binary Search Objective: Implement both linear search and binary search, and see which one performs better
Linear Search Vs Binary Search Objective: Implement both linear search and binary search, and see which one performs better given an array 1,000 randomly generated whole numbers (between 0-999), a number picked to search that array at random, and conducting these tests 20 times. Each time the search is conducted the number of checks (IE number of times the loop is ran or the number of times the recursive method is called) needs to be counted and at the end the total number of checks should be averaged A few notes Each algorithm (linear search and binary search) is ran 20 times mennd pied wh andan values from 0-999 A value to be searched in the said array is randomly selected from the range 0-999 o Each algorithm must display if that number was successfully found Each algorithm must display the number of checks it took to determine the above answer It is advisable to create a method that returns the sorted array Populate the array with random numbers o Search the array next o Return whether or not the value was found in the array Implement both searches as a method o However instead of returning whether or not it found the number it should return the number of checks o Whether the value is or is not found can be printed in the method Binary search is fairly simple to create using recursion o Do not count the out of bounds or stopping index as a check
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
