Let A be a sequence of n ≥ 0 real numbers. A subsequence of A is a sequence of contiguous elements of A. A maximum scoring subsequence of A is a subsequence with largest sum of its elements , which can be found in O(n) time by Kadane's dynamic programming algorithm. We consider in this paper two problems involving maximal scoring subsequences of a sequence. Both of these problems arise in the context of buffer memory minimization in computer networks. The first one, which is called INSERTION IN A SEQUENCE WITH SCORES (ISS), consists in inserting a given real number x in A in such a way to minimize the sum of a maximum scoring subsequence of the resulting sequence, which can be easily done in O(n 2 ) time by successively applying Kadane's algorithm to compute the maximum scoring subsequence of the resulting sequence corresponding to each possible insertion position for x. We show in this paper that the ISS problem can be solved in linear time and space with a more specialized algorithm. The second problem we consider in this paper is the SORTING A SEQUENCE BY SCORES (SSS) one, stated as follows: find a permutation A ′ of A that minimizes the sum of a maximum scoring subsequence. We show that the SSS problem is strongly NP-Hard and give a 2-approximation algorithm for it. * This work is partially supported by FUNCAP/INRIA (Ceará State, Brazil/France) and CNPq (Brazil) research projects. A slightly different version of this paper has been submitted for journal publication. † Partially supported by a doctoral scholarship of CAPES (Programa de Demanda Social). ‡ http://www.lia.ufc.br/˜pargo § Partially supported by a FUNCAP grant.
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 (x 0 →p 0 ) , . . . , A (x m−1 →p m−1 ) optimally in O(n + m) time, improving on the straightforward and suboptimal strategy of applying Kadane's algorithm to each sequence A (x i →p i ) , 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.
scite is a Brooklyn-based organization that helps researchers better discover and understand research articles through Smart Citations–citations that display the context of the citation and describe whether the article provides supporting or contrasting evidence. scite is used by students and researchers from around the world and is funded in part by the National Science Foundation and the National Institute on Drug Abuse of the National Institutes of Health.