1computer sciences. 2 growth of functions 3.2 standard notations and common functions

11
1 Computer Sciences

Upload: winifred-byrd

Post on 17-Jan-2018

215 views

Category:

Documents


0 download

DESCRIPTION

Standard notations and common functions  Logarithms.  Exponential.  Factorials. Objective

TRANSCRIPT

Page 1: 1Computer Sciences. 2 GROWTH OF FUNCTIONS 3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS

Computer Sciences 1

Page 2: 1Computer Sciences. 2 GROWTH OF FUNCTIONS 3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS

Computer Sciences 2

GROWTH OF FUNCTIONS

3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS

Page 3: 1Computer Sciences. 2 GROWTH OF FUNCTIONS 3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS

• Standard notations and common functions

Logarithms .

Exponential.

Factorials.

Objective

Page 4: 1Computer Sciences. 2 GROWTH OF FUNCTIONS 3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS

3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS

Page 5: 1Computer Sciences. 2 GROWTH OF FUNCTIONS 3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS
Page 6: 1Computer Sciences. 2 GROWTH OF FUNCTIONS 3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS

Computer Sciences 6

RECURRENCES

TUTORIAL 3

Page 7: 1Computer Sciences. 2 GROWTH OF FUNCTIONS 3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS

Recurrences.

• Substitution method,

• Recursion-tree method,

• Master method.

Objective

Page 8: 1Computer Sciences. 2 GROWTH OF FUNCTIONS 3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS

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

Page 9: 1Computer Sciences. 2 GROWTH OF FUNCTIONS 3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS

Draw the recursion tree for the recurrence :

T(n) = 2 T(n/3) + T(n/4) + n2

Recursion TreeExercise 2:

Page 10: 1Computer Sciences. 2 GROWTH OF FUNCTIONS 3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS

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

Page 11: 1Computer Sciences. 2 GROWTH OF FUNCTIONS 3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS

• 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