有序列表二分查找
public boolean binarySearch(List<Integer> numbers, int value) {
if (numbers.size() == 0 || numbers.isEmpty()) {
return false;
}
int m = numbers.size() / 2;
int mValue = numbers.get(m);
if (value == mValue) {
return true;
}
if (value > mValue) {
List<Integer> rightNumbers = numbers.subList(m + 1, numbers.size());
return binarySearch(rightNumbers,value);
}
if (value < mValue) {
List<Integer> leftNumbers = numbers.subList(0, m);
return binarySearch(leftNumbers,value);
}
return false;
}
合并两个有序的数组,合并后依然有序
public int[] merge(int[] a,int[] b) {
int ai = 0;int bi = 0;int j = 0;
int[] result =