Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication
description
Transcript of Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication
![Page 1: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/1.jpg)
Algorithms for the Maximum Algorithms for the Maximum Subarray Problem Based on Subarray Problem Based on
Matrix MultiplicationMatrix Multiplication
Authours : Hisao Tamaki & Takeshi Tokuyama
Speaker : Rung-Ren Lin
![Page 2: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/2.jpg)
OutlineOutline
IntroductionIntroduction ½-approximation½-approximation Funny matrix multiplicationFunny matrix multiplication ReductionReduction Two little programsTwo little programs
![Page 3: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/3.jpg)
IntroductionIntroduction ½-approximation½-approximation Funny matrix multiplicationFunny matrix multiplication ReductionReduction Two little programsTwo little programs
![Page 4: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/4.jpg)
DefinitionDefinition
Given an Given an mm by by nn matrix, output the matrix, output the maximum subarray.maximum subarray.
![Page 5: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/5.jpg)
HistoryHistory
Bentley proposes this problem in Bentley proposes this problem in 1984.1984.
Kadane’s algorithm solves 1-D Kadane’s algorithm solves 1-D problem in linear time.problem in linear time.
Kadane’s idea does not work for the Kadane’s idea does not work for the 2-D case.2-D case.
There’s an O(There’s an O(mm22nn) algorithm by using ) algorithm by using Kadane’s idea.Kadane’s idea.
![Page 6: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/6.jpg)
Kadane’s algorithmKadane’s algorithm
S(i) = A(i) + max{S(i-1), 0}
i
![Page 7: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/7.jpg)
PreprocessingPreprocessing
Given a matrix Given a matrix AA[1…[1…mm][1…][1…nn], we can ], we can compute compute BB[1…[1…mm][1…][1…nn] in O(] in O(mnmn) time ) time such that such that BB[[ii][][jj] represents the sum of ] represents the sum of AA[1…[1…ii][1…][1…jj].].
![Page 8: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/8.jpg)
IntroductionIntroduction½-approximation½-approximation Funny matrix multiplicationFunny matrix multiplication ReductionReduction Two little programsTwo little programs
![Page 9: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/9.jpg)
n
m
Time = mn/2 * 2 = mn
![Page 10: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/10.jpg)
n
m
Time = mn/4 * 4= mn
![Page 11: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/11.jpg)
Time ComplexityTime Complexity
OO((mnmn*log*logmm))
![Page 12: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/12.jpg)
IntroductionIntroduction ½-approximation½-approximationFunny matrix multiplicationFunny matrix multiplication ReductionReduction Two little programsTwo little programs
![Page 13: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/13.jpg)
DefinitionDefinition
Given two Given two nn by by nn matrices, matrices, AAijij & & BBijij
CCijij = max = maxk=1 to nk=1 to n{{AAikik + + BBkjkj}}
A B C
jj
i i
![Page 14: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/14.jpg)
HistoryHistory
Funny matrix multiplication is well-Funny matrix multiplication is well-studied, since its computational studied, since its computational complexity is known to be equivalent complexity is known to be equivalent to that of “all-pairs shortest paths”.to that of “all-pairs shortest paths”.
Fredman constructs a subcubic Fredman constructs a subcubic algorithm with running timealgorithm with running time ::
3
13
log
loglog*
n
nn
![Page 15: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/15.jpg)
Cont’dCont’d
Takaoka improved toTakaoka improved to
in 1992.in 1992.
2
13
log
loglog*
n
nn
![Page 16: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/16.jpg)
IntroductionIntroduction ½-approximation½-approximation Funny matrix multiplicationFunny matrix multiplicationReductionReduction Two little programsTwo little programs
![Page 17: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/17.jpg)
DefinitionDefinition
TT((mm, , nn)) :: computing time for the computing time for the mm by by nn matrix matrix
TTrowrow((mm, , nn)) :: row-centeredrow-centered
TTcolcol((mm, , nn)) :: column-centeredcolumn-centered
TT((mm, , nn) = ) = TTrowrow((mm, , nn) + ) + TTcolcol((mm, , nn) +) +
44TT((mm/2, /2, nn/2)/2)
![Page 18: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/18.jpg)
Cont’dCont’d
TTcentercenter((mm, , nn)) :: row & column-centeredrow & column-centered
TTrowrow((mm, , nn) = ) = TTcentercenter((mm, , nn) + 2) + 2TTrowrow((mm, , nn/2)/2)
TTcolcol((mm, , nn) = ) = TTcentercenter((mm, , nn) + 2) + 2TTcolcol((mm/2, /2, nn))
![Page 19: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/19.jpg)
ReductionReduction
A B
C D
![Page 20: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/20.jpg)
Cont’dCont’d
Let Let AA, , BB, , CC, , DD[1…[1…mm/2][1…/2][1…nn/2] be the /2] be the sum of the given area.sum of the given area.
XXijij = max = maxkk=1 to =1 to mm/2/2{{AAikik + + CCjkjk}}
YYijij = max = maxkk=1 to =1 to mm/2/2{{BBikik + + DDjkjk}}
output = max{output = max{XXij + ij + YYijij}}
![Page 21: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/21.jpg)
IntroductionIntroduction ½-approximation½-approximation Funny matrix multiplicationFunny matrix multiplication ReductionReductionTwo little programsTwo little programs
![Page 22: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/22.jpg)
13-card13-card
![Page 23: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/23.jpg)
PacmanPacman
![Page 24: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/24.jpg)
ChallengesChallenges
It’s difficult to search 3-D models.It’s difficult to search 3-D models.
![Page 25: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/25.jpg)
![Page 26: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication](https://reader035.fdocuments.net/reader035/viewer/2022062222/56814967550346895db6bc2c/html5/thumbnails/26.jpg)
The EndThe End