2D_subarray_sum

# 2D_subarray_sum - COMP 271H Design and Analysis of...

• Notes
• 3

This preview shows pages 1–2. Sign up to view the full content.

COMP 271H Design and Analysis of Algorithms 2006 Fall Semester Reference material 2 Maximal Sub-rectangle Problem 1. Introduction: This article focuses the 2-dimensional extension of linear contiguous subarray problem. The problem is that given a N × N square blocks, with total N 2 blocks, find the sub- rectangle from this square blocks such that the sum is maximal among all possible rect- angles. For example, given the 4 × 4 square blocks 0 - 2 - 7 0 9 2 - 6 2 - 4 1 - 4 1 - 1 8 0 - 2 The maximal sub-rectangle should locate at 9 2 - 4 1 - 1 8 with the sum equals to 15. 2. The way to solve this problem: First, we need to think what is the performance to solve it in brute force. We will count number of sub-rectangles for N = 1, N = 2 and N = 3 respectively. Size of N N = 1 N = 2 N = 3 Number of sub-rectangles 1 9 36 Value of N 2 1 4 9 Value of N 3 1 8 27 Using this simple analysis, we can guess that the number of sub-rectangles will at least grow in O ( N 3 ) time (Just a rough guess). Also, in the worst case, we need to sum a rectangle in O ( N 2 ) time. So, the brute force algorithm may run in at least

This preview has intentionally blurred sections. Sign up to view the full version.

This is the end of the preview. Sign up to access the rest of the document.
• Spring '10
• may
• English, SEPTA Regional Rail, Black-and-white films, Analysis of algorithms, Computational complexity theory, Jaguar Racing, square blocks

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern