A Linear Time Algorithm for the k Maximal Sums Problem

  • Gerth Stølting Brodal
  • Allan Grønlund Jørgensen
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4708)

Abstract

Finding the sub-vector with the largest sum in a sequence of n numbers is known as the maximum sum problem. Finding the k sub-vectors with the largest sums is a natural extension of this, and is known as the k maximal sums problem. In this paper we design an optimal O(n + k) time algorithm for the k maximal sums problem. We use this algorithm to obtain algorithms solving the two-dimensional k maximal sums problem in O(m 2·n + k) time, where the input is an m ×n matrix with m ≤ n. We generalize this algorithm to solve the d-dimensional problem in O(n 2d − 1 + k) time. The space usage of all the algorithms can be reduced to O(n d − 1 + k). This leads to the first algorithm for the k maximal sums problem in one dimension using O(n + k) time and O(k) space.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Bentley, J.: Programming pearls: algorithm design techniques. Commun. ACM 27(9), 865–873 (1984)CrossRefMathSciNetGoogle Scholar
  2. 2.
    Fukuda, T., Morimoto, Y., Morishita, S., Tokuyama, T.: Data mining with optimized two-dimensional association rules. ACM Trans. Database Syst. 26(2), 179–213 (2001)MATHCrossRefGoogle Scholar
  3. 3.
    Allison, L.: Longest biased interval and longest non-negative sum interval. Bioinformatics 19(10), 1294–1295 (2003)CrossRefGoogle Scholar
  4. 4.
    Gries, D.: A note on a standard strategy for developing loop invariants and loops. Sci. Comput. Program. 2(3), 207–214 (1982)MATHCrossRefMathSciNetGoogle Scholar
  5. 5.
    Tamaki, H., Tokuyama, T.: Algorithms for the maximum subarray problem based on matrix multiplication. In: Proceedings of the ninth annual ACM-SIAM symposium on Discrete algorithms, pp. 446–452. Society for Industrial and Applied Mathematics, Philadelphia, PA, USA (1998)Google Scholar
  6. 6.
    Takaoka, T.: Efficient algorithms for the maximum subarray problem by distance matrix multiplication. Electr. Notes Theor. Comput. Sci. 61 (2002)Google Scholar
  7. 7.
    Takaoka, T.: A new upper bound on the complexity of the all pairs shortest path problem. Inf. Process. Lett. 43(4), 195–199 (1992)MATHCrossRefMathSciNetGoogle Scholar
  8. 8.
    Bae, S.E., Takaoka, T.: Algorithms for the problem of k maximum sums and a vlsi algorithm for the k maximum subarrays problem. In: 7th International Symposium on Parallel Architectures, Algorithms, and Networks (I-SPAN 2004), Hong Kong, SAR, China, 10-12 May 2004, pp. 247–253. IEEE Computer Society, Los Alamitos (2004)Google Scholar
  9. 9.
    Bengtsson, F., Chen, J.: Efficient algorithms for k maximum sums. In: Fleischer, R., Trippen, G. (eds.) ISAAC 2004. LNCS, vol. 3341, pp. 137–148. Springer, Heidelberg (2004)Google Scholar
  10. 10.
    Bae, S.E., Takaoka, T.: Improved algorithms for the k-maximum subarray problem for small k. In: Wang, L. (ed.) COCOON 2005. LNCS, vol. 3595, pp. 621–631. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  11. 11.
    Bae, S.E., Takaoka, T.: Improved algorithms for the k-maximum subarray problem. Comput. J. 49(3), 358–374 (2006)CrossRefGoogle Scholar
  12. 12.
    Lin, T.-C., Lee, D.T.: Randomized algorithm for the sum selection problem. In: Deng, X., Du, D.-Z. (eds.) ISAAC 2005. LNCS, vol. 3827, pp. 515–523. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  13. 13.
    Cheng, C.-H., Chen, K.-Y., Tien, W.-C., Chao, K.-M.: Improved algorithms for the k maximum-sums problems. Theoretical Computer Science 362(1-3), 162–170 (2006)MATHCrossRefMathSciNetGoogle Scholar
  14. 14.
    Chao, K.M., Liu, H.F.: Personal communication (2007)Google Scholar
  15. 15.
    Eppstein, D.: Finding the k shortest paths. SIAM J. Comput. 28(2), 652–673 (1999)CrossRefMathSciNetGoogle Scholar
  16. 16.
    Frederickson, G.N.: An optimal algorithm for selection in a min-heap. Inf. Comput. 104(2), 197–214 (1993)MATHCrossRefMathSciNetGoogle Scholar
  17. 17.
    Driscoll, J.R., Sarnak, N., Sleator, D.D., Tarjan, R.E.: Making data structures persistent. Journal of Computer and System Sciences 38(1), 86–124 (1989)MATHCrossRefMathSciNetGoogle Scholar
  18. 18.
    Sleator, D.D., Tarjan, R.E.: Self adjusting heaps. SIAM J. Comput. 15(1), 52–69 (1986)MATHCrossRefMathSciNetGoogle Scholar
  19. 19.
    Crane, C.A.: Linear lists and priority queues as balanced binary trees. Technical Report STAN-CS-72-259, Dept. of Computer Science, Stanford University (1972)Google Scholar
  20. 20.
    Knuth, D.E.: The art of computer programming, sorting and searching, 2nd edn., vol. 3. Addison Wesley Longman Publishing Co., Inc., Redwood City, CA, USA (1998)Google Scholar
  21. 21.
    Blum, M., Floyd, R.W., Pratt, V.R., Rivest, R.L., Tarjan, R.E.: Time bounds for selection. J. Comput. Syst. Sci. 7(4), 448–461 (1973)MATHCrossRefMathSciNetGoogle Scholar
  22. 22.
    Williams, J.W.J.: Algorithm 232: Heapsort. Communications of the ACM 7(6), 347–348 (1964)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2007

Authors and Affiliations

  • Gerth Stølting Brodal
    • 1
  • Allan Grønlund Jørgensen
    • 1
  1. 1.BRICS, MADALGO, Department of Computer Science, University of AarhusDenmark

Personalised recommendations