Article ID | Journal | Published Year | Pages | File Type |
---|---|---|---|---|
4952205 | Theoretical Computer Science | 2017 | 10 Pages |
Abstract
The maximal sum of a sequence A of n real numbers is the greatest sum of all elements of any linearly contiguous and possibly empty subsequence of A. It can be computed in O(n) time by means of Kadane's algorithm. Letting A(xâp) denote the sequence which results from inserting a real number x just after element A[pâ1], we show how the maximal sum of A(xâp) can be computed in O(1) worst-case time for any given x and p, provided that an O(n) time preprocessing step has already been executed on A. In particular, this implies that, given m pairs (x0,p0),â¦,(xmâ1,pmâ1), we can compute the maximal sums of sequences A(x0âp0),â¦,A(xmâ1âpmâ1) optimally in O(n+m) time, improving on the straightforward and suboptimal strategy of applying Kadane's algorithm to each sequence A(xiâpi), which takes a total of Î(nm) time. We also show that the same time bound is attainable when circular subsequences of A(xâp) are taken into account. Our algorithms are easy to implement in practice, and they were motivated by a buffer minimization problem on wireless mesh networks.
Keywords
Related Topics
Physical Sciences and Engineering
Computer Science
Computational Theory and Mathematics
Authors
Ricardo C. Corrêa, Pablo M.S. Farias,