class ArrayDemo {
public static void main(String[]args)
{
int[]arr={..............};
index =sort(arr,..);
System.out.println("index="+index)
}
public static void sort( int[]arr; int key ){
int min ,max,mid;
{
int min = 0;
int max=arr.length-1;
while( min<=max ){
mid=(min+man)>>1;
if(key < mid)
max=mid-1;{
else if(key > mid)
min=mid+1;
else
ruturn mid;
}
return -1;
}
|
|