Transcript
Page 1: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication

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

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

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

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

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

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

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

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

n

m

Time = mn/2 * 2 = mn

Page 10: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication

n

m

Time = mn/4 * 4= mn

Page 11: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication

Time ComplexityTime Complexity

OO((mnmn*log*logmm))

Page 12: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication

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

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

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

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

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

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

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

ReductionReduction

A B

C D

Page 20: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication

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

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

13-card13-card

Page 23: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication

PacmanPacman

Page 24: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication

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
Page 26: Algorithms for the Maximum Subarray Problem Based on Matrix Multiplication

The EndThe End


Recommended