Question: The searching technique in Problem 2 is called as Sequential Search or Linear Search. It works well for small or unsorted arrays. However, for large

The searching technique in Problem 2 is called as Sequential Search or Linear Search. It works well for small or unsorted arrays. However, for large arrays linear searching is inefficient especially if the array is sorted. For this we use a different searching technique to find a number. This search algorithm considers a sorted array. The algorithm locates the middle element of the array and compares it to the search key. If theyre equal, the search key is found and the array subscript of that element is returned. If theyre not equal, the problem is reduced to searching onehalf of the array. If the search key is less than the middle element of the array, the first half of the array is searched, otherwise the second half is searched. If the search key is not found in the specified subarray (piece of the original array), the algorithm is repeated on one-quarter of the original array. The search continues until the search key is equal to the middle element of a subarray, or until the subarray consists of one element thats not equal to the search key (i.e., the search key is not found). Write a program to find whether a given number is present using a sorted array using the searching technique as mentioned above.

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!