多个独立插入序列的最大线性和与循环和的线性时间计算
Linear Time Computation of the Maximal Linear and Circular Sums of Multiple Independent Insertions into a Sequence
摘要:
n个实数的序列A的最大和是A的任意严格邻接且可能为空的子序列的所有元素的最大和,并且它可以通过Kadane算法在O(n)时间内计算。让“A^(x -> p)”表示在元素“A[p-1]”和“A[p]"之间插入实数“x”所产生的序列,我们展示了对于任何给定的“x”和“p”,如何在“O(1)”最坏情况下计算“A^(x -> p)”的最大和,假设“A”已经执行了“O(n)”时间预处理步骤。特别地,这意味着,给定“m”对“(x_0,p_0),.,(x_{m-1},p_{m-1})",我们可以计算序列“A^(x_0 -> p_0),.,A^(x_{m-1} -> p_{m-1})”在“O(n+m)”的时间内,这与问题输入大小所施加的下限相匹配,并且还改进了将Kadane算法应用于每个序列“A^(x_i -> p_i)"的直接策略,其总共花费“Theta(n.m)”时间。然而,我们的主要贡献是获得相同的时间界的更复杂的问题,计算的最大总和的所有元素的任何严格或循环连续的,可能是空的子序列“A^(x -> p)"。我们的算法是很容易实现的,在实践中,他们的动机,并找到应用程序在无线网状网络的缓冲区最小化问题。
英文摘要:
The maximal sum of a sequence "A" of "n" real numbers is the greatest sum of all elements of any strictly contiguous and possibly empty subsequence of "A", and 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" between elements "A[p-1]" and "A[p]", 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 "(x_0, p_0), ..., (x_{m-1}, p_{m-1})", we can compute the maximal sums of sequences "A^(x_0 -> p_0), ..., A^(x_{m-1} -> p_{m-1})" in "O(n+m)" time, which matches the lower bound imposed by the problem input size, and also improves on the straightforward strategy of applying Kadane's algorithm to each sequence "A^(x_i -> p_i)", which takes a total of "Theta(n.m)" time. Our main contribution, however, is to obtain the same time bound for the more complicated problem of computing the greatest sum of all elements of any strictly or circularly contiguous and possibly empty subsequence of "A^(x -> p)". Our algorithms are easy to implement in practice, and they were motivated by and find application in a buffer minimization problem on wireless mesh networks.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。