write a Java program to find the number of comparisons using binarySearch and th
ID: 3627673 • Letter: W
Question
write a Java program to find the number of comparisons using binarySearch and the sequential search algorithm as follows:Suppose list is an array of 1000 elements.
a. Use a random number generator to fill list.
b. Use any sorting algorithm to sort list.
c. Search list for some items as follows:
i. Use the binary search algorithm to search the list
ii. Use the binary search algorithm to search list, switching to a sequential search when the size of the search list reduces less than 15.
d. Print the number of comparisons for c.i and c.ii. If the item is found in the list, then print its position.
Explanation / Answer
#include #include #include int fermatTest (int n) { int a, result, i; a = rand() % n; coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.