#include <iostream>
using namespace std;
void binarysearch(int arr[],int s,int size);
void binarysearch(int arr[],int s,int size)
{
int
lower=0,higher=size-1,m;
while(lower<=higher)
{
m=(lower+higher)/2;
if(s==arr[m])
{
cout<<"Search found at index"<<m<<endl;
return;
}
else
if(s>arr[m])
lower=m+1;
else
higher=m-1;
}
cout<<"Search not found"<<endl;
}
/******************************************/
0 comments:
Post a Comment