Selecting Sums in Arrays

  • Authors:
  • Gerth Stølting Brodal;Allan Grønlund Jørgensen

  • Affiliations:
  • BRICS, MADALGO, Department of Computer Science, University of Aarhus, Denmark;BRICS, MADALGO, Department of Computer Science, University of Aarhus, Denmark

  • Venue:
  • ISAAC '08 Proceedings of the 19th International Symposium on Algorithms and Computation
  • Year:
  • 2008

Quantified Score

Hi-index 0.00

Visualization

Abstract

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.