1Computer Sciences. 2 GROWTH OF FUNCTIONS 3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS.
-
Upload
winifred-byrd -
Category
Documents
-
view
215 -
download
0
description
Transcript of 1Computer Sciences. 2 GROWTH OF FUNCTIONS 3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS.
Computer Sciences 1
Computer Sciences 2
GROWTH OF FUNCTIONS
3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS
• Standard notations and common functions
Logarithms .
Exponential.
Factorials.
Objective
3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS
Computer Sciences 6
RECURRENCES
TUTORIAL 3
Recurrences.
• Substitution method,
• Recursion-tree method,
• Master method.
Objective
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 )
Substitution
Draw the recursion tree for the recurrence :
T(n) = 2 T(n/3) + T(n/4) + n2
Recursion TreeExercise 2:
Master method
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).
Conclusion