Binary Search:- The Binary Search is one of the most important searching technique in Searching Algorithm. The one of property of this searching algorithm is, all the elements are in sorted order in array. The worst case and average case complexity of this algo is O(log n) and gives O(1) in best case.
This algorithm is based on divide and conquer approach.firstly we define the lower and upper bound of array This algo first find the middle element in the array. if searching element is less than the mid(middle) element it set mid+1 element to up(upper bound) and if searching element is greater than the mid(middle) element it set mid-1 element to lw(lower bound). If the mid(middle) element is equal to searching element the element is found.
Worst Case:- This indicate that the searching element is found at last position or first position in the array.
Best Case:- This indicate that the searching element is found at the middle in the array at first division(lw+up/2).
printf("Enter the size of an Array:=");
printf("Enter the Element of an Array\n");
printf("Enter the Number You Want to Search:=");
printf("%d is found at position %d",se,mid+1);
printf("%d is not found",se);