efficient heuristic algorithms for the maximum subarray problem rung-ren lin and kun-mao chao
TRANSCRIPT
![Page 1: Efficient heuristic algorithms for the maximum subarray problem Rung-Ren Lin and Kun-Mao Chao](https://reader036.vdocuments.site/reader036/viewer/2022082506/5697bfbb1a28abf838ca0cda/html5/thumbnails/1.jpg)
Efficient heuristic algorithms for the maximum subarray problem
Rung-Ren Lin and Kun-Mao Chao
![Page 2: Efficient heuristic algorithms for the maximum subarray problem Rung-Ren Lin and Kun-Mao Chao](https://reader036.vdocuments.site/reader036/viewer/2022082506/5697bfbb1a28abf838ca0cda/html5/thumbnails/2.jpg)
Preview
Trying to guess the answer intelligently. Preliminary experiments show that these appr
oaches are very promising for locating the maximum subarray in a given two-dimensional array.
![Page 3: Efficient heuristic algorithms for the maximum subarray problem Rung-Ren Lin and Kun-Mao Chao](https://reader036.vdocuments.site/reader036/viewer/2022082506/5697bfbb1a28abf838ca0cda/html5/thumbnails/3.jpg)
Review of Maximum Subarray
Bentley posed the maximum subarray problem in his book “Programming Pearls” in 1984.
He introduces Kadane's algorithm for the one-dimensional case, whose time is linear.
![Page 4: Efficient heuristic algorithms for the maximum subarray problem Rung-Ren Lin and Kun-Mao Chao](https://reader036.vdocuments.site/reader036/viewer/2022082506/5697bfbb1a28abf838ca0cda/html5/thumbnails/4.jpg)
Cont’d
Given an m×n array of numbers, Bentley solved the problem in O(m2n) time.
An improvement O(m2n(loglogm/logm)0.5) was given by Tamaki et al. in 1998.This algorithm is heavily recursive and complicated.
![Page 5: Efficient heuristic algorithms for the maximum subarray problem Rung-Ren Lin and Kun-Mao Chao](https://reader036.vdocuments.site/reader036/viewer/2022082506/5697bfbb1a28abf838ca0cda/html5/thumbnails/5.jpg)
Applications
20 25 30 35 40 45 50 55 60$
$$
$$$
$$$$
$$$$$
$$$$$$
$$$$$$$
![Page 6: Efficient heuristic algorithms for the maximum subarray problem Rung-Ren Lin and Kun-Mao Chao](https://reader036.vdocuments.site/reader036/viewer/2022082506/5697bfbb1a28abf838ca0cda/html5/thumbnails/6.jpg)
Cont’d
![Page 7: Efficient heuristic algorithms for the maximum subarray problem Rung-Ren Lin and Kun-Mao Chao](https://reader036.vdocuments.site/reader036/viewer/2022082506/5697bfbb1a28abf838ca0cda/html5/thumbnails/7.jpg)
Heuristic Methods
Given a 2-D array A[1..m][1..n], let TL[i][j] denote the sum of the rectangle A[1..i][1..j].
-3 1 2
2 -1 0
0 -2 1
-3 -2 0
-1 -1 1
-1 -3 0
A TL
![Page 8: Efficient heuristic algorithms for the maximum subarray problem Rung-Ren Lin and Kun-Mao Chao](https://reader036.vdocuments.site/reader036/viewer/2022082506/5697bfbb1a28abf838ca0cda/html5/thumbnails/8.jpg)
Constructing TL Matrix
for i = 2 to n do
for j = 1 to n do
A[i][j] = A[i][j] + A[i-1][j]
-3 1 2
2 -1 0
0 -2 1
-3 -1 2
-1 0 2
-1 -2 3
A A’
![Page 9: Efficient heuristic algorithms for the maximum subarray problem Rung-Ren Lin and Kun-Mao Chao](https://reader036.vdocuments.site/reader036/viewer/2022082506/5697bfbb1a28abf838ca0cda/html5/thumbnails/9.jpg)
Cont’d
for i = 2 to n do
for j = 1 to n do
A’[j][i] = A’[j][i] + A’[j][i-1]
-3 1 2
-1 0 2
-1 -2 3
-3 -2 0
-1 -1 1
-1 -3 0
A’ TL
![Page 10: Efficient heuristic algorithms for the maximum subarray problem Rung-Ren Lin and Kun-Mao Chao](https://reader036.vdocuments.site/reader036/viewer/2022082506/5697bfbb1a28abf838ca0cda/html5/thumbnails/10.jpg)
Computing an Arbitrary Rectangle
![Page 11: Efficient heuristic algorithms for the maximum subarray problem Rung-Ren Lin and Kun-Mao Chao](https://reader036.vdocuments.site/reader036/viewer/2022082506/5697bfbb1a28abf838ca0cda/html5/thumbnails/11.jpg)
How to guess ?
Each rectangle can be computed by TL matrix, and the answer is MAX( + - - ).
the larger the better. the smaller the better.
![Page 12: Efficient heuristic algorithms for the maximum subarray problem Rung-Ren Lin and Kun-Mao Chao](https://reader036.vdocuments.site/reader036/viewer/2022082506/5697bfbb1a28abf838ca0cda/html5/thumbnails/12.jpg)
Cont’d
We try only those entries which are in the top k-th, or in the bottom k-th for a given k.
We test only O(k) times instead of O(n) times. Since there are in total O(m2) pairs, this step takes O(km2).
![Page 13: Efficient heuristic algorithms for the maximum subarray problem Rung-Ren Lin and Kun-Mao Chao](https://reader036.vdocuments.site/reader036/viewer/2022082506/5697bfbb1a28abf838ca0cda/html5/thumbnails/13.jpg)
4-Corner
![Page 14: Efficient heuristic algorithms for the maximum subarray problem Rung-Ren Lin and Kun-Mao Chao](https://reader036.vdocuments.site/reader036/viewer/2022082506/5697bfbb1a28abf838ca0cda/html5/thumbnails/14.jpg)
Happy New Year!!
![Page 15: Efficient heuristic algorithms for the maximum subarray problem Rung-Ren Lin and Kun-Mao Chao](https://reader036.vdocuments.site/reader036/viewer/2022082506/5697bfbb1a28abf838ca0cda/html5/thumbnails/15.jpg)
Interesting Questions
128 gold. The way to heaven and hell. 10 smart prisoners.