Professional Documents
Culture Documents
Change
Input: An integer n and a set of coin denominations {c1,c2,…,cr}
with c1 > c2> … >cr
Output: A set of coins d1,d2,…,dr such that , minimized
1. For Do
2.
3. While Do
4.
5.
6. End
7. Return
n-1
• Computing
– Check Table 2, page 157:
– Rewrite =
• Finally, = =
1. For Do
2. For Do
3. For Do
4.
5. End
6. End
7. End
8. Return
\Omega()
CSCE 235 Algorithms: An Introduction 57
Big-Theta Definition
• Definition: Let f and g be two functions f,g: NR+. We say
that
f(n) (g(n))
(read: f is Big-Theta of g) if there exists a constant c1, c2 R+
and an noN such that for every integer n n0 we have
c1g(n) f(n) c2g(n)
2.
Then f(n)(g(n))
• The above can be proven using calculus, but for our purposes,
the limit method is sufficient for showing asymptotic inclusions
• Always try to look for algebraic simplifications first
• If and both diverge or converge on zero or infinity, then you
need to apply the l’Hôpital Rule
CSCE 235 Algorithms: An Introduction 71
(Guillaume de) L’Hôpital Rule
• Theorem (L’Hôpital Rule):
– Let f and g be two functions,
– if the limit between the quotient exists,
– Then, it is equal to the limit of the derivative of
the numerator and the denominator
limn = limn
–
–
(product rule)
–
– careful!
• Constant O(1)
• Logarithmic O(log (n))
• Linear O(n)
• Polylogarithmic O(logk (n))
• Quadratic O(n2)
• Cubic O(n3)
• Polynominal O(nk) for any k>0
• Exponential O(kn), where k>1
• Factorial O(n!)
CSCE 235 Algorithms: An Introduction 86
Conclusions
• Evaluating asymptotics is easy, but remember:
– Always look for algebraic simplifications
– You must always give a rigorous proof
– Using the limit method is (almost) always the best
– Use L’Hôpital Rule if need be
– Give as simple and tight expressions as possible