Question: Implement a method that will search a given array using the linear search algorithm and a recursive binary search algorithm in Java. Test the program
Implement a method that will search a given array using the linear search algorithm and a recursive binary search algorithm in Java.
Test the program for array sizes N = 16, 32, 64, 128, 256, 512, 1024, 2048, ......, 225. Initialize the array with random numbers between the ranges 1 through N and use the same array for testing linear search and binary search. Remember to sort the array before using binary search. Use a text file with 1,000 random numbers in the range 1 through 225 as the search keys.
Compare the execution time for linear search and binary search. Include the time taken for sorting with the binary search time (you have to sort only once for each array size).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
