Journal of Discrete Algorithms
Hi-index | 0.00 |
In an array of n numbers each of the $\binom{n}{2}+n$contiguous subarrays define a sum. In this paper we focus onalgorithms for selecting and reporting maximal sums from an arrayof numbers. First, we consider the problem of reporting ksubarrays inducing the k largest sums among all subarraysof length at least l and at most u. For thisproblem we design an optimal O(n + k)time algorithm. Secondly, we consider the problem of selecting asubarray storing the k'th largest sum. For this problem weprove a time bound of θ(n · max{1,log(k/n)}) by describing an algorithm withthis running time and by proving a matching lower bound. Finally,we combine the ideas and obtain an O(n·max {1,log(k/n)}) time algorithm that selects asubarray storing the k'th largest sum among all subarraysof length at least l and at most u.