320 likes | 579 Views
Algorithms. Ch 3: Growth of Functions Ming-Te Chi. 3.1 Asymptotic notation . A way to describe behavior of function in the limit. asymptotically tight bound. g(n) is an asymptotic tight bound for f(n). "=" abuse equality. “is a member of” All c i and n 0 are positive numbers.
E N D
Algorithms Ch 3: Growth of Functions Ming-Te Chi Ch3 Growth of Functions
3.1 Asymptotic notation • A way to describe behavior of function in the limit. Ch3 Growth of Functions
asymptotically tight bound g(n) is an asymptotic tight bound for f(n). • "=" abuse equality. “is a member of” • All ci and n0are positive numbers. Ch3 Growth of Functions
The definition of required every member of be asymptotically nonnegative. Ch3 Growth of Functions
Example: • In general, if Ch3 Growth of Functions
asymptotic upper bound Ch3 Growth of Functions
asymptotic lower bound Ch3 Growth of Functions
Theorem 3.1. • For any two functions f(n) and g(n), if and only if and . Ch3 Growth of Functions
Remarks: • The asymptotic upper bound by O-notation may or may not be asymptotically tight. • The bound 2n2 = O(n2) is asymptotically tight but the bound 2n = O(n2) is not. • The o-notation is used to denote an upper bound that is not asymptotically tight. • is read as “little-oh of g of n” Ch3 Growth of Functions
o-notation Ch3 Growth of Functions
ω-notation Ch3 Growth of Functions
5 asymptotic notations • Difference between big-oh and little-oh? • Etc. Ch3 Growth of Functions
Properties: • Transitivity • Reflexivity • Symmetry Ch3 Growth of Functions
Transpose symmetry Ch3 Growth of Functions
Trichotomy (三分法) • a < b, a = b, or a > b. (only one condition holds for all real number a & b) • Not all functions are asymptotically comparable. (For two functions f and g, it may be the case that neither nor • e.g., can not be compared using the asymptotic notation. Since oscillates between 0 and 2. Ch3 Growth of Functions
2.2 Standard notations and common functions • Monotonicity: • A function f is monotonically increasing if m n implies f(m) f(n). • A function f is monotonically decreasing if m n implies f(m) f(n). • A function f is strictly increasing if m < n implies f(m) < f(n). • A function f is strictly decreasing if m < n implies f(m) > f(n). Ch3 Growth of Functions
Floor and ceiling Ch3 Growth of Functions
Modular arithmetic • For any integer a and any positive integer n, the value a mod n is the remainder (or residue) of the quotient a/n : a mod n =a -a/nn. • If(a mod n) = (b mod n). We write a b (mod n) and say that a is equivalent to b, modulo n. • We write a≢b (mod n) if a is not equivalent to b modulo n. Ch3 Growth of Functions
Polynomials v.s. Exponentials • Polynomials: • Polynomial in n of degree d, a nonnegative integer. • A function is polynomial bounded if for some constant k. Ch3 Growth of Functions
Polynomials v.s. Exponentials • Exponentials: • Any positive exponential function grows faster than any polynomial. Ch3 Growth of Functions
Logarithms • A function f(n) is polylogarithmically bounded if , for some constant k • for any constant a > 0. • Any positive polynomial function grows faster than any polylogarithmic function. Ch3 Growth of Functions
Factorials Ch3 Growth of Functions
Factorials • Stirling’s approximation can be used to show Ch3 Growth of Functions
Factorials • Also, for n>=1, we have where Ch3 Growth of Functions
Function iteration For example, if , then Ch3 Growth of Functions
The iterative logarithm function Ch3 Growth of Functions
Since the number of atoms in the observable universe is estimated to be about , which is much less than , we rarely encounter a value of n such that . Ch3 Growth of Functions
Fibonacci numbers Ch3 Growth of Functions
Fibonacci numbers • Fibonacci numbers grow exponentially. Ch3 Growth of Functions