Abstract
Given a sequence of n real numbers and an integer parameter k , the problem studied in this paper is to compute k subsequences of consecutive elements with the sums of their elements being the largest, the second largest, …, and the k th largest among all possible range sums of the input sequence. For any value of k , 1 ≤ k ≤ n ( n + 1 ) / 2 , we design a fast algorithm that takes O ( n + k log n ) time in the worst case to compute and rank all such subsequences. We also prove that our algorithm is optimal for k = O ( n ) by providing a matching lower bound. Moreover, our algorithm is an improvement over the previous results on the maximum sum subsequences problem (where only the subsequences are requested and no ordering with respect to their relative sums will be determined). Furthermore, given the fact that we have computed the ℓ th largest sums, our algorithm retrieves the ( ℓ + 1 ) th largest sum in O ( log n ) time, after O ( n ) time of preprocessing.
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have
Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.