Logic:-
Binary search logic is simple and very useful. Let's take an example of an array and try to perform a Binary search operation on it. First, we have to know that Binary search applies is only sorted data, so if data is not sorted then you can not apply Binary search.
Now come to point so basically we divide the array data in two parts and compare the elements first iteration, and compare the element of the mid element of an array if the element is less than the array element then again divide the array from staring to midpoint into 2 part and again matches the element if again array element is greater than the element than again divide the array into two parts. If the array element is less the element than again divide the array into two parts starting to mid to end and repeat the step until to the last divide the array.
Output:
==================================
C Program For Binary Search
==================================
Enter The Size Of An Array :7
Enter An Elements Of An Array
15
115
175
250
365
808
999
Enter The Number You Want To Search In An Array :808
Number Found In an Array
need an explanation for this answer? contact us directly to get an explanation for this answer