Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Exponentials
1
a
m n
2)(a ) = a mn
1)a 1 =
3)a m a n = a m+ n
n
x
4) Lt n 1 + = e x
n
Logarithms
x = logba is the exponent for a = bx.
Binary log: lg a = log2a
Natural log: ln a = logea
For all real a>0, b>0, c>0 and n
1)a = b logb a
2) log c (ab) = log c a + log c b
3) log b a n = n log b a
4) log b a =
log c a
= log c a * log b c
log c b
5) log b (1 / a ) = log b a
6) log c (a / b) = log c a log c b
7) log b a =
1
log a b
Monotonicity
f(n) is
(i) monotonically increasing if m n f(m) f(n).
(ii) monotonically decreasing if m n f(m) f(n).
(iii) strictly increasing if m < n f(m) < f(n).
(iv) strictly decreasing if m > n f(m) > f(n).
Sequences
Arithmetic sequence
a,a+d,a+2d,..,a+(n-1)d,..
nth term of the sequence tn= a+(n-1)d
Sum to first to n terms Sn=n/2[2a+(n-1)d]
Geometric sequence
a, ar,ar2, ar3,,arn-1,
Sum to first to n terms
Sn=
Sn=
( )
if r>1
( )
if r<1
S=
|r|<1
1 = b a + 1
i =a
i = 1 + 2 + + n =
i =1
= 12 + 2 2 + + n 2 =
i =1
n(n + 1)
2
n(n + 1)(2n + 1)
= ( n 2 )
6
4
i =1
n
xk = 1+ x + x2 + + xn =
k =0
x
k =0
1
1 x
x n +1 1
x 1
ic i = c + 2c 2 + + nc n =
i =1
(n + 1)c n +1 + nc n + 2 + c
(c 1) 2
1 1
1 n 1
+ + + = = ln(n) + O(1)
2 3
n k =1 k
1
n1
ni=1 1 dx + 1 = ln n + 1
i
x
Solution:
= 1p + 2 p + + n p
i =1
1
n p +1 O(n p +1 )p 0
p +1
lg k n lg n
k =1
Factorials
n! = 1.2.3.4.n
n! nn, thus n!=O(nn)
Stirlings Approximation
n
n!= 2n
e
1
1 +
n
2. Asymptotic Notation
Asymptotic efficiency of algorithms is concerned with how the running time increases with the
size of the input in the limit, i.e. as the size of the input increases without bound.
Definition:
Asymptotic complexity is running time of an algorithm as a function of input size n for large n
2 cn
c = 1 and n0= 2
2) 1000n2+1000n = O(n2)
1000n2+1000n 1000n2+ n2 =1001n2
3) Examples of of functions inO (n2)
n2, n2+n, 5n2+6n, 1000n2+100n+10.
Also, n, n/100, n1.99999, n2/lg lg n
Examples
1) 5n2 = (n)
c, n0 such that: 0 cn 5n2
cn 5n2
c = 1 and n0 = 1
c1=
o-notation
o(g(n)) = {f(n): c > 0, n0 > 0 such that
n n0, we have 0 f(n) < cg(n)}.
g(n) is an upper bound for f(n) that is not asymptotically tight.
w notation
w(g(n)) = {f(n): c > 0, n0 > 0 such that
n n0, we have 0 cg(n) < f(n)}.
g(n) is a lower bound for f(n) that is not asymptotically tight.
Comparisons:
f (n) is asymptotically smaller than g(n) if f (n) =o(g(n)).
f (n) is asymptotically larger than g(n) if f (n) =(g(n)).
Comparison of Functions
f (n) = O(g(n)) a b
f (n) = (g(n)) a b
f (n) = (g(n)) a = b
f (n) = o(g(n)) a < b
f (n) = w (g(n)) a > b
Note: But, No trichotomy. i.e., we might not be able to compare functions.
Example: n1+sin n and n
PROPERTIES
1) f(n) = (g(n)) f(n) = (g(n)). Therefore, (g(n)) O (g (n)).
2) f(n) = (g(n)) f(n) = O(g(n)).Therefore,(g(n)) (g (n)).
3) Theorem :
For any two functions g(n) and f(n),
f(n) = (g(n)) iff f(n) = O(g(n)) and f(n) = (g(n)).
i.e., (g(n)) = O(g(n)) (g(n)
()
=
)
1. If A=0, then
f(n)=o(g(n))
or
f(n)=O(g(n)) and f(n) (g(n))
2 If A=, then
f(n)= (g(n))
or
f(n)= (g(n)) and f(n) (g(n))
3. If A0 and finite , then f(n) = (g(n))
13)
nb
limn c n = 0
nb = O(c n )
Put lg n for n ,b for a and 2b for c in (i)
(lg n)a
(lg n)a
nb
=0
na
limn n b = nab 0
Practice Problems
1. Function g is an upper bound on function f iff for all x,
(a) g(x) f (x);
(b) g(x) f (x);
(c) g = O( f ); (d) f = (g);
2. Function g is a lower bound on function f iff for all x,
(a) g(x) f (x);
(b) g(x) f (x);
(c) f = O(g);
3. Big-Omega notation expresses
(a) tight bounds; (b) upper bounds;
(d) g = (f);
III Transitive
III Transitive
9. n1/ lg n is
(a) (1)
10. 4lg n is
(a) (1)
11. n2 23lg n is
(a) (n2)
12.
III Transitive
(b) (lg n)
(c) ( n)
(d) (lg n)
(b) (lg n)
(c) (n lg n)
(d) (n2)
(b) (n4)
(c) (n5)
(d) (n6)
Which of the following correctly describes the asymptotic order of growth of following
functions:
f1=lg10 n
f2=n5
f3=2n
(a) f1< f2< f3
(b) f2< f1< f3 (c) f3< f2< f1 (d) f1< f3< f2
13. Which of the following correctly describes the asymptotic order of growth of following
functions
f1=2lg n
lg n
f2=2
f3=n2
f2=n1/ lg n
lg n
f3=2
Problems:
For each of the following pairs of functions, either f(n) is O(g(n)), f(n) is (g(n)), or f(n) =
(g(n)). Determine which relationship is correct.
1) f(n) = log n2; g(n) = log n + 5
2) f(n) = n; g(n) = log n2
3) f(n) = log log n; g(n) = log n
4) f(n) = n; g(n) = log2 n
5) f(n) = n log n + n; g(n) = log n
6) f(n) = 10; g(n) = log 10
7) f(n) = 2n; g(n) = 10n2
8) f(n) = 2n; g(n) = 3n
Solutions:
1) f(n) = (g(n))
2) f(n) = (g(n))
3) f(n) = O(g(n))
4) f(n) = (g(n))
5) f(n) = (g(n))
6) f(n) = (g(n))
7) f(n) = (g(n))
8) f(n) = O(g(n))