2D_subarray_sum

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

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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- 2- 7 9 2- 6 2- 4 1- 4 1- 1 8- 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) time....
View Full Document

Page1 / 3

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

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online