Unformatted text preview: the length of the longest path from this node to a leaf. ) 5 Suppose the changes of stock price of GOOGLE in the past n days are stored in array A[1. . n ]. We would like to know in which period, the accumulative increase is the largest. For example, in the past 7 days, if the changes are +3, 6, +5, +2, 3, +4, 4, then, the largest increase is from day 3 to day 6. The accumulative increase is 5+23+4 = 8. Please design a divide and conquer algorithm that finds the period such that the accumulative increase is the largest. That is to find two indices i and j (1 ≤ i ≤ j ≤ n ) such that ∑ = j i k k A ] [ is the largest. Analyze the complexity of your algorithm. 1...
View
Full Document
 Winter '05
 Shen
 Algorithms, Recursion, Divide and conquer algorithm, accumulative increase, nelement heap

Click to edit the document details