10 likes | 219 Views
作业 1 --- 答案. unimodalSearch (A[1..n]) low = 1; high = n; while (low < high) mid = low + (high - low)/2; if (A[mid] < A[mid+1]) low = mid + 1; else high = mid; return A[low]; // here low==high anyway.
E N D
作业1 --- 答案 unimodalSearch(A[1..n]) low = 1; high = n; while(low < high) mid = low + (high - low)/2; if (A[mid] < A[mid+1]) low = mid + 1; else high = mid; return A[low]; // here low==high anyway