package revise;
public class binarySearch {
public static int binaryS(int[] b,int data)
{
int low=0,high=b.length-1;
int med=(low+high)/2;
while(low<=med)
{
if(b[med]>data)
{
high=med-1;
}
if(data>b[med])
{
low=med+1;
}
else
{
return med;
}
}
return -1;
}
public static void main(String[] args) {
int[] a= {1,10,22,30,35,44,66,78,80};
int result=binaryS(a,78);
System.out.println(result);
}
}