分而治之
递归
/**
* 递归(分而治之)
*
* @param arr
* @param leftIndex
* @param rightIndex
* @return
*/
public int min(int[] arr, int leftIndex, int rightIndex) {
if (leftIndex == rightIndex) {
return arr[leftIndex];
}
// 中间值
int middle = leftIndex + ((rightIndex - leftIndex) >> 1);
int leftMin = min(arr, leftIndex, middle);
int rightMin = min(arr, middle + 1, rightIndex);
return Math.min(leftMin, rightMin);
}