Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7683591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:49:44+00:00 2026-05-31T18:49:44+00:00

Given an array of real-valued numbers, A[1..n,1..n] , I wish to find the sub-array

  • 0

Given an array of real-valued numbers, A[1..n,1..n], I wish to find the sub-array

B = A[i..j,s..t]

with 1 <= i <= j <= n, and 1 <= s <= t <= n

such that the sum of the numbers in B is maximized. Is it possible to solve this using dynamic programming? I spoke to one of the OR professors at Aarhus University, and he didn’t know how to do it, and said that he had difficulty seeing how it could have the optimal substructure quality.

But IS it possible? If yes, how? If not, why?

I already know of an algorithm that runs in O(n^3) time, by reducing it to n(n+1)/2 subproblems of complexity O(n), but that seems like it’s a bit slow. I know that an optimal algorithm would run in Omega(n) time, but I’m hoping that dynamic programming could be used for making it run in O(n^2) time.

Original question summarized

I added this section because I felt some people has misinterpreted the point of my question. The original question was:

  1. Is it possible to use dynamic programming to solve the above problem in O(n^2) time? If yes, how? If no, why not?

Additional questions:

I added a new questions here. More might be added later:

  1. In order to use dynamic programming, I need to make use of solutions to easily solved subproblems (Or else the point is moot). The structure of the problem is such, that if we take a subarray B = A[1..m,1..m] of A[1..n,1..n] where m < n, then the optimal solution for array B is at most as good as in A, trivially, since the same solution is feasible in A. To use dynamic programming, it is therefore reasonable to ask: What is the relationship between the optimal subarray of A[1..i,1..i] and the optimal subarray of A[1..i+1,1..i+1]?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:49:45+00:00Added an answer on May 31, 2026 at 6:49 pm

    From The Algorithmist, if you have an n by n array, the best you can do is O(n^3):

    • First, calculate the vertical prefix sum for all columns (an O(n^2) algorithm).
    • Second, assume that the maximum sub-array will be between row a and row b, inclusive. There are only O(n^2) a, b pairs such that a < b. Try each of them.
    • Since we already have the vertical prefix sum for all columns, the sum of elements in arr[a..b][c] for column c can be computed in O(1) time. This allows us to imagine each column sum as if it is a single element of a one-dimensional array across all columns (one dimensional array with one row and n columns).
    • There’s an O(n) algorithm to compute the maximum sub-array for a one-dimensional array, known as Kadane’s Algorithm.
    • Applying the Kadane’s algorithm inside each a and b combination gives the total complexity of O(n3).

    Given that you have an n by 2 array, you can get it down to O(n^2). The key, as above, is to use Kadane’s algorithm

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given an array like this: Array => ( [0] => 1, [1] => 2,
This is the PHP code given <?php $aColumns = array( 'engine', 'browser', 'platform', 'version',
I have a string. I need to replace all instances of a given array
Given an array of n Objects, let's say it is an array of strings
Given an array of characters which forms a sentence of words, give an efficient
Given an array of integers, what is the simplest way to iterate over it
Given an array like {one two, three four five}, how'd you calculate the total
Given an array of items, each of which has a value and cost ,
Given an array of ids $galleries = array(1,2,5) I want to have a SQL
Given an array with n values, for example: $arr[] = 'ABCDEFABC'; $arr[] = 'ABCDEFDEF';

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.