Search for question
Question

(10 pts.) Suppose you are given an array A[1...n] of integers which can be positive, negative or 0. Asub-array is a contiguous sequence of elements from A. In particular, for any two indexes i and j with 1 ≤ i ≤ j ≤ n, A[ij] is the sub-array that starts at index i and ends at j. The sum of the sub-array A[i] is the sum of all the numbers it contains: A[i] + A[i + 1] + ..... + A[j]. For example, ifA = [5, 1, -3, -2, 4, 0], the sum of A[03] is 1 and the sum of A[14] is 0. Given A, design a divide-and-conquer algorithm, running in O(n log n) time, to find the sub-array of minimum sum. For example, in the array A = [5, 1, -3, -2, 4, 0], the sub-array of minimum sum is A[2, 3] with sum -5. You will need to describe your algorithm (please refer to "Describing an Algorithm" on top for more instructions), prove the correctness of your algorithm, and analyze the running time of your algorithm.

Fig: 1