Write a C++ program to find the number of comparisons using binarySearch and the
ID: 3634075 • Letter: W
Question
Write a C++ 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 reduces to less then 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.
Suppose that L is a list is of length n and it is sorted using insertion sort. If L is already sorted in the reverse
order, show that the number of comparisons is (1/2) (n2 (squared) - n) and the number of item assignments is
(1/2) (n2 (squared) +3n) -2.