二分法查找
1 public int search(int left, int right, int searchKey) { 2 int cur = (left + right)/2; 3 if (ele[cur] == searchKey) { 4 return cur; 5 } 6 else if (left > right) { 7 return 0; 8 } 9 else { 10 if (ele[cur] < searchKey) { 11 12 return search(cur +1, right, searchKey); 13 } else { 14 return search(left, cur-1, searchKey); 15 } 16 } 17 }
未完待续!