Master Method The Precise Statement Design and Analysis of Algorithms I... THE MASTER METHODNextcore AI -Gopal Shangari Cool Feature : a “black box” for solving recurrences.. AssumpFon
Trang 1Master Method The Precise
Statement
Design and Analysis
of Algorithms I
Trang 2THE MASTER METHOD
Nextcore AI -Gopal Shangari
Cool Feature : a “black box” for solving
recurrences.
AssumpFon : all subproblems have
equal size.
Trang 3RECURRENCE FORMAT
Nextcore AI -Gopal Shangari
where
a = number of recursive calls (>= 1ti
b = input size shrinkage factor ( >
1ti
d = exponent in running Fme of “combine step” (>=0ti [a,b,d independent of n ]
1 Base Case : T(nti <= a constant for all sufficiently small n
2 For all larger n :
Trang 4The Master Method
•
Nextcore AI -Gopal Shangari
Trang 5Master Method
Examples
Design and Analysis
of Algorithms I
Trang 6The Master Method
Trang 7EXAMPLE #1
Nextcore AI -Gopal Shangari
Merge Sort
a = 2
b = 2
d = 1
a
Trang 81, 2, 0 [Case 1]
Trang 9Example #3
Integer MulKplicaKon Algorithm # 1
a = 4
b = 2
d = 1
Same as gradeNschool algorithm
Trang 10BeP er than the gradeN school
algorithm!!!
Trang 11Example #5
Strassen’s Matrix MulKplicaKon Algorithm
a = 7
b = 2
d = 2
=> beats the nạve iteraKve algorithm !
Trang 12Example #6
FicKKous Recurrence
a = 2
b = 2
d = 2