Abstract

The maximum subarray problem is to find the array portion that maximizes the sum of array elements in it. For K disjoint maximum subarrays, Ruzzo and Tompa gave an O(n) time solution for one-dimension. This solution is, however, difficult to extend to two-dimensions. While a trivial solution of O(Kn3) time is easily obtainable for a two-dimensional array of size n × n, little study has been undertaken to improve the time complexity. We first propose an O(n + K log K) time solution for one-dimension. This is asymptotically equivalent to Ruzzo and Tompa's when sorted order is needed. Based on this, we achieve O(n3 + Kn2 log n) time for two-dimensions. This is cubic time when K ≤ n/ log n. We also show that this upper bound does not exceed O(n3 log n) for K > n, namely O(n3 + min (K,n) · n log n).

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call