Algorithm to find the submatrix with the greatest sum of its elements?

AI Thread Summary
The discussion centers on finding the submatrix with the greatest sum from a real-valued matrix A, exploring algorithmic approaches beyond brute force. A proposed method involves using Kadane's algorithm on each submatrix defined by pairs of left and right columns, resulting in a time complexity of O(n^3). While this is a viable solution, participants note the existence of potentially faster algorithms, although specific details are not provided. The maximum subarray problem, a related one-dimensional case, can be solved in O(n) time, but a linear solution for the two-dimensional case remains elusive. The best-known solutions fall between O(n^2) and O(n^3), indicating room for further exploration in optimizing the algorithm.
Jamin2112
Messages
973
Reaction score
12
This is a challenge problem I thought of: Given a real-valued matrix A, develop an algorithm that finds the submatrix with the greatest sum of its element. (If there's a tie, just return an arbitrary submatrix that's tied for the win.)

Is there a way other than brute force?
 
Technology news on Phys.org
Sounds like an application for dynamic programming. Use Kadane's algorithm on each submatrix using right and left column pairs -

O(n^3). I believe there is a faster algorithm but I do not know it offhand.
 
I've seen this problem before -- Wikipedia calls the 1D problem the "Maximum subarray problem" and it can be solved in O(n). I spent some time trying to find a solution linear in the number of matrix elements, but never found one. I believe the best solution was more than O(n^2) but less than O(n^3) (see the references at the end of the wikipedia article).
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top