This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full 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
- Spring '10