百科的释义:
对于区间[a,b]上连续不断且f(a)·f(b)<0的函数y=f(x),通过不断地把函数f(x)的零点所在的区间一分为二,使区间的两个端点逐步逼近零点,进而得到零点近似值的方法叫二分法。
public static final int a(int[] a,int key){
int low = 0;
int high =a.length-1;
int mid;
while (low<=high){
mid =(low+high)/2;
if(a[mid]<key){
low = mid+1;
}else if(a[mid]>key){
high = mid-1;
}
else if(a[mid]==key){
return mid;
}
}
return -1;
}