Binary Search algorithm
Binary searching is technique to search specified element in a shorted array of Integers.It is mostly used in case of searching when there is a given shorted array.Its time complexity is O(log N).
Algorithm:
int Binarysearch(int a[],int size,int key){
int low=0,high=size-1;
boolean find=false;
int mid=0;
while(low<=high){
mid=(high+low)/2;
if(key==a[mid]){
find=true;
break;
}
else if(key<a[mid])
high=mid;
else
low=mid+1;
}
if(find)
return mid;
else
return -1;
}
i think u should write "sorted" instead of "shorted"