Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 12 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
12
Dung lượng
1,42 MB
Nội dung
Design and Analysis of Algorithms I Master Method The Precise Statement THE MASTER METHOD Cool Feature : a “black box” for solving recurrences AssumpFon : all subproblems have equal size Nextcore AI Gopal Shangari RECURRENCE FORMAT Base Case : T(nti = 1ti b = input size shrinkage factor ( > 1ti d = exponent in running Fme of “combine step” (>=0ti Nextcore AI Gopal [a,b,d independent of n ] Shangari The Master Method • Nextcore AI Gopal Shangari Master Method Examples Design and Analysis of Algorithms I The Master Method EXAMPLE #1 Merge Sort a=2 b=2 d=1 a Nextcore AI Gopal Shangari 1, 2, [Case 1] Example #3 a=4 b=2 d=1 Integer MulKplicaKon Algorithm # Same as gradeNschool algorithm BeP er than the gradeN school algorithm!!! Example #5 Strassen’s Matrix MulKplicaKon Algorithm a=7 b=2 d=2 => beats the naïve iteraKve algorithm ! Example #6 FicKKous Recurrence a=2 b=2 d=2 ... Shangari Master Method Examples Design and Analysis of Algorithms I The Master Method EXAMPLE #1 Merge Sort a=2 b=2 d =1 a Nextcore AI Gopal Shangari 1, 2, [Case 1] Example #3 a=4 b=2 d =1 Integer... recursive calls (>= 1ti b = input size shrinkage factor ( > 1ti d = exponent in running Fme of “combine step” (>=0ti Nextcore AI Gopal [a,b,d independent of n ] Shangari The Master Method • Nextcore...THE MASTER METHOD Cool Feature : a “black box” for solving recurrences AssumpFon : all subproblems have