Question: Write a program to find if the element is present in the array using binary search The list is int list [ 1 7 ]

Write a program to find if the element is present in the array using binary search The list is
int list[17]={2,4,7,10,11,28,34,45,50,59,60,66,69,70,75,89,95};
The prototype of the function is
int binarySearch(int array[], int size, int value);
Find the number of iterations it takes to find the key. If the key is not found, it should still say how many iterations it takes to search the array.
Here is a sample run for a key present in the array:
Enter the element to search: 66
It takes 4 iterations to find the key 66
66 is at index 11
Here is a sample run for a key not present in the array:
Enter the element to search: 9
After 4 iterations 9 is not found!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!