二分法查询(某个网站的面试题)

public class BiSearchTest {
	// 非递归
	public static int BiSearchNonRecursive
	(int Array[], int low, int length, int key)
	{
		int high = length - 1;
		while(low<=high){
			int half = (low+high) >>> 1;
			if(key==Array[half]){
				return half;
			}
			if(key>Array[half]){
				low = half + 1 ;
			}else if (key>> 1;
		 if(keyArray[high] || Array[low]>Array[high]){
			 return -1;
		 }
		 if(key>Array[half]){
			 return BiSearchRecursive(Array,half+1,high,key);
		 }
		 else if(key

你可能感兴趣的:(二分法查询(某个网站的面试题))