Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Â
Lecture 4 - Growth of Functions (1).ppt
1. Introduction to Algorithms
(3rd edition)
by Cormen, Leiserson, Rivest & Stein
Chapter 3: Growth of Functions
(slides enhanced by N. Adlai A. DePano)
2. Overview
ïŻ Order of growth of functions provides a
simple characterization of efficiency
ïŻ Allows for comparison of relative
performance between alternative
algorithms
ïŻ Concerned with asymptotic efficiency of
algorithms
ïŻ Best asymptotic efficiency usually is best
choice except for smaller inputs
ïŻ Several standard methods to simplify
asymptotic analysis of algorithms
3. Asymptotic Notation
ïŻ Applies to functions whose domains are the
set of natural numbers:
N = {0,1,2,âŠ}
ïŻ If time resource T(n) is being analyzed, the
functionâs range is usually the set of non-
negative real numbers:
T(n) ï R+
ïŻ If space resource S(n) is being analyzed, the
functionâs range is usually also the set of
natural numbers:
S(n) ï N
4. Asymptotic Notation
ïŻ Depending on the textbook,
asymptotic categories may be
expressed in terms of --
a. set membership (our textbook):
functions belong to a family of functions
that exhibit some property; or
b. function property (other textbooks):
functions exhibit the property
ïŻ Caveat: we will formally use (a) and
informally use (b)
5. The Î-Notation
f
c1 â g
n0
c2 â g
Î(g(n)) = { f(n) : âc1, c2 > 0, n0 > 0 s.t. ân â„ n0:
c1 · g(n) †f(n) †c2 â g(n) }
12. Standard Notation and
Common Functions
ïŻ Monotonicity
A function f(n) is monotonically
increasing if m ïŁ n implies f(m) ïŁ f(n) .
A function f(n) is monotonically
decreasing if m ïŁ n implies f(m) ïł f(n) .
A function f(n) is strictly increasing
if m < n implies f(m) < f(n) .
A function f(n) is strictly decreasing
if m < n implies f(m) > f(n) .
14. Standard Notation and
Common Functions
ïŻ Exponentials
For all n and aïł1, the function an is the exponential
function with base a and is monotonically
increasing.
ïŻ Logarithms
Textbook adopts the following convention
lg n = log2n (binary logarithm),
ln n = logen (natural logarithm),
lgk n = (lg n)k (exponentiation),
lg lg n = lg(lg n) (composition),
lg n + k = (lg n)+k (precedence of lg).
15. Standard Notation and
Common Functions
ïŻ Factorials
For all n the function n! or ân factorialâ is
given by
n! = n ïŽ (nï1) ïŽ (n ï 2) ïŽ (n ï 3) ïŽ âŠ ïŽ 2 ïŽ 1
It can be established that
n! = o(nn)
n! = ï·(2n)
lg(n!) = ï(nlgn)
16. ïŻ Functional iteration
The notation f (i)(n) represents the function f(n)
iteratively applied i times to an initial value of n,
or, recursively
f (i)(n) = n if i=0
f (i)(n) = f(f (iï1)(n)) if i>0
Example:
If f (n) = 2n
then f (2)(n) = f (2n) = 2(2n) = 22n
then f (3)(n) = f (f (2)(n)) = 2(22n) = 23n
then f (i)(n) = 2in
Standard Notation and
Common Functions
17. ïŻ Iterated logarithmic function
The notation lg* n which reads âlog star of nâ is
defined as
lg* n = min {iïł0 : lg(i) n ïŁ 1
Example:
lg* 2 = 1
lg* 4 = 2
lg* 16 = 3
lg* 65536 = 4
lg* 265536 = 5
Standard Notation and
Common Functions
18. ïŻ Asymptotic analysis studies how the
values of functions compare as their
arguments grow without bounds.
ïŻ Ignores constants and the behavior of
the function for small arguments.
ïŻ Acceptable because all algorithms are
fast for small inputs and growth of
running time is more important than
constant factors.
Things to Remember
19. ïŻ Ignoring the usually unimportant details,
we obtain a representation that succinctly
describes the growth of a function as
its argument grows and thus allows us to
make comparisons between algorithms in
terms of their efficiency.
Things to Remember
20. Tips to Help Remember
ïŻ May be helpful to make the following
âanalogiesâ (remember, we are comparing
rates of growth of functions)