Transcript Document

Computer Sciences
1
GROWTH OF FUNCTIONS
3.2 STANDARD NOTATIONS AND COMMON
FUNCTIONS
Computer Sciences
2
Objective
• Standard notations and common functions
 Logarithms .
 Exponential.
 Factorials.
RECURRENCES
TUTORIAL 3
Computer Sciences
6
Objective
 Recurrences.
• Substitution method,
• Recursion-tree method,
• Master method.
Exercise 1:
Use the substitution method to show that T(n) = O(n2 lg (n/2)) if :
• T (n) = 2 T (n/2) + n
Solution :
T(n) ≤ 2 T((n2/2) lg (n/4)) +n
≤ 2 c (n2/2) lg (n/4) +n
= cn2 lg (n/4) + n
= cn2 lg n - 2 cn2 +n
≤ cn2 lg n
:. T(n) = O(n2lg n )
Exercise 2:
Draw the recursion tree for the recurrence :
T(n) = 2 T(n/3) + T(n/4) + n2
Exercise 3:
For each of the following recurrences, give an expression for the
runtime T (n) if the recurrence can be solved with the Master Theorem.
• T (n) = 3T (n/2) + n^2
• T (n) = 4T (n/2) + n^2
• T (n) = 16T (n/4) + n
• Standard notations and common functions.
• Substitution method,
 Guess the form of the solution.
 Use mathematical induction to find the constants and
show that the solution works.
• Recursion-tree method,
 Using recursion trees to generate good guesses.
• Master method.
 T(n) = a T(n/b) + f(n).