How do i use C++ to find the number of comparisons using binary Search and the sequential search algorithm as asked below.
Suppose list is an array of 1000 elements:
- Use a random number generator to fill list.
- Use bubble sort algorithm to sort the list.
- Search the list for some items as follows:
- Use the binary search algorithm to search the list.
- Use the binary search algorithm to search the list, switching to a sequential search when the size of the search list reduces to less than 15.
- Print the number of comparisons for question 1.3.1 and 1.3.2. If the item is found in the list then print its position.