问题:
给定一个数组,判定数组中的元素是否有序(升序)。
public static boolean isArrayInSortedOrder(int array[], int lastIndex) {
if (lastIndex == 0) return true;
if (array[lastIndex] < array[lastIndex - 1]) return false;
return isArrayInSortedOrder(array, lastIndex - 1);
}
时间复杂度O(n),空间复杂度O(n)