摘要:
4.1-1返回只包含绝对值最小的元素的子数组。4.1-2Maximun-Subarray(A) max = -infinity for i = 1 to A.length sum = 0 for j = i to A.length sum = sum + A[i] if sum > max max = sum low = i high = j return (low, high, max)每次内循环都利用上次累加的结果,避免重复运算。外层循环执行n次,第i次外循环内层循环执行n-i+1次,所以总的时间复杂度为$\Theta (n^2)$。4.1-3这道题$n_0$... 阅读全文