1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method,...
-
Upload
percival-haynes -
Category
Documents
-
view
224 -
download
1
Transcript of 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method,...
![Page 1: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/1.jpg)
Computer Sciences Department 1
![Page 2: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/2.jpg)
![Page 3: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/3.jpg)
Objectives
• Recurrences.
Substitution Method,
Recursion-tree method,
Master method
![Page 4: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/4.jpg)
Computer Sciences Department 4
Recurrence
![Page 5: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/5.jpg)
Computer Sciences Department 5
A recurrence is an equation or inequality that describes a function in terms of its value on smaller inputs.
Example: MERGE-SORT procedure could be described by
the recurrence:
recurrence
![Page 6: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/6.jpg)
Computer Sciences Department 6
Substitution Method,
Recursion-tree method,
Master method
Recurrence Methods
![Page 7: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/7.jpg)
Computer Sciences Department 7
The substitution method for solving recurrences entails two steps: 1. Guess the form of the solution. 2. Use mathematical induction to find the
constants and show that the solution works. The substitution method can be used to
establish either upper or lower bounds on a recurrence.
The substitution method
![Page 8: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/8.jpg)
Computer Sciences Department 8
![Page 9: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/9.jpg)
Computer Sciences Department 9
As an example, let us determine an upper bound on the recurrence
lgn/2=lgn-lg2
![Page 10: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/10.jpg)
Computer Sciences Department 10
A recursion tree is best used to generate a good guess, which is then verified by the substitution method.
Using recursion trees to generate good guesses.
The recursion-tree method
![Page 11: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/11.jpg)
Computer Sciences Department 11
Solution
![Page 12: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/12.jpg)
Computer Sciences Department 12
Solution
![Page 13: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/13.jpg)
Computer Sciences Department 13
Solution
![Page 14: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/14.jpg)
Computer Sciences Department 14
Solution
![Page 15: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/15.jpg)
Computer Sciences Department 15
Solution
![Page 16: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/16.jpg)
Computer Sciences Department 16
For example
We start by focusing on finding an upper bound for the solution.
create a recursion tree for the recurrence
we assume that n is an exact power of 4
![Page 17: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/17.jpg)
Computer Sciences Department 17
![Page 18: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/18.jpg)
Computer Sciences Department 18
![Page 19: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/19.jpg)
Computer Sciences Department 19guess
![Page 20: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/20.jpg)
Computer Sciences Department 20
![Page 21: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/21.jpg)
Computer Sciences Department 21
The master method
![Page 22: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/22.jpg)
Computer Sciences Department 22
![Page 23: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/23.jpg)
Computer Sciences Department 23
and
and
Conditions of using the master method
1
2
3
5
4
and
![Page 24: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/24.jpg)
Computer Sciences Department 24
![Page 25: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/25.jpg)
Computer Sciences Department 25
?
Try
![Page 26: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/26.jpg)
Computer Sciences Department 26
TRY (LAB)
![Page 27: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/27.jpg)
Computer Sciences Department 27
![Page 28: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/28.jpg)
Computer Sciences Department 28
![Page 29: 1Computer Sciences Department. Objectives Recurrences. Substitution Method, Recursion-tree method, Master method.](https://reader035.fdocuments.us/reader035/viewer/2022081513/5697c02c1a28abf838cd9272/html5/thumbnails/29.jpg)
Computer Sciences Department 29
Proof of the master theorem (no need)