Improved algorithms for the K-maximum subarray problem for small K

  • Authors:
  • Sung E. Bae;Tadao Takaoka

  • Affiliations:
  • Department of Computer Science and Software Engineering, University of Canterbury, Christchurch, New Zealand;Department of Computer Science and Software Engineering, University of Canterbury, Christchurch, New Zealand

  • Venue:
  • COCOON'05 Proceedings of the 11th annual international conference on Computing and Combinatorics
  • Year:
  • 2005

Quantified Score

Hi-index 0.01

Visualization

Abstract

The maximum subarray problem for a one- or two-dimensional array is to find the array portion that maiximizes the sum of array elements in it. The K-maximum subarray problem is to find the K subarrays with largest sums. We improve the time complexity for the one-dimensional case from $O(min\{K+n\log^2 n, n\sqrt{K}\})$ for 0 ≤ K ≤ n(n–1)/2 to O(nlog K + K2) for K ≤ n. The latter is better when $K \le \sqrt n\log n$. If we simply extend this result to the two-dimensional case, we will have the complexity of O(n3log K + K2n2). We improve this complexity to O(n3) for $K \le \sqrt{n}$.