For this first project, you will create a linear search and binary search and record the time it takes for searchingfor various numbers. There is starter code at the end of this For this first project, you will create a linear search and binary search and record the time it takes for searchingfor various numbers. There is starter code at the end of this,
– Array (5%)Create an array of integers with size 1,000,000 and fill it with numbers 1 – 1,000,000 in order.
Linear Search (25%)Create a linear search method called linearSearch with the method signature below. This method takes thearray of integers and the number we are searching for and should return the index of the number in the array or-1 if not found.
public static int linearSearch(int a[ ], int search)
– Binary Search (60%)Create a binary search method called binarySearch with the method signature below. This method takes thearray of integers and the number we are searching for and should return the index of the number in the array or-1 if not found.
public static int binarySearch(int a[ ], int search)
Starter Code: Main.java
/*
Record the time for the following search:
Linear Search:
1:
100:
1,000:
10,000:
100,000:
1,000,000:
1,000,001:
Binary Search:
1:
100:
1,000:
10,000:
100,000:
1,000,000:
1,000,001:
*/
class Main {public static void main(String[ ] args) {
}
}