algorithms for the maximum subarray problem based on matrix multiplication
DESCRIPTION
Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication. Authours : Hisao Tamaki & Takeshi Tokuyama Speaker : Rung-Ren Lin. Outline. Introduction ½ -approximation Funny matrix multiplication Reduction Two little programs. Introduction ½ -approximation - PowerPoint PPT PresentationTRANSCRIPT
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
OutlineOutline
IntroductionIntroduction ½-approximation½-approximation Funny matrix multiplicationFunny matrix multiplication ReductionReduction Two little programsTwo little programs
IntroductionIntroduction ½-approximation½-approximation Funny matrix multiplicationFunny matrix multiplication ReductionReduction Two little programsTwo little programs
DefinitionDefinition
Given an Given an mm by by nn matrix, output the matrix, output the maximum subarray.maximum subarray.
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.
Kadane’s algorithmKadane’s algorithm
S(i) = A(i) + max{S(i-1), 0}
i
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].].
IntroductionIntroduction½-approximation½-approximation Funny matrix multiplicationFunny matrix multiplication ReductionReduction Two little programsTwo little programs
n
m
Time = mn/2 * 2 = mn
n
m
Time = mn/4 * 4= mn
Time ComplexityTime Complexity
OO((mnmn*log*logmm))
IntroductionIntroduction ½-approximation½-approximationFunny matrix multiplicationFunny matrix multiplication ReductionReduction Two little programsTwo little programs
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
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
Cont’dCont’d
Takaoka improved toTakaoka improved to
in 1992.in 1992.
2
13
log
loglog*
n
nn
IntroductionIntroduction ½-approximation½-approximation Funny matrix multiplicationFunny matrix multiplicationReductionReduction Two little programsTwo little programs
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)
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))
ReductionReduction
A B
C D
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}}
IntroductionIntroduction ½-approximation½-approximation Funny matrix multiplicationFunny matrix multiplication ReductionReductionTwo little programsTwo little programs
13-card13-card
PacmanPacman
ChallengesChallenges
It’s difficult to search 3-D models.It’s difficult to search 3-D models.
The EndThe End