Asymptotic Notations
Asymptotic Notations
Asymptotic Notations*
Dr. Ying Lu
[email protected]
August 30, 2012
http://www.cse.unl.edu/~ylu/raik283
*slides refrred to
http://www.aw-bc.com/info/levitin
Design and Analysis of Algorithms Chapter 2.2
Big-oh
t(n) O(g(n))
Small-oh
t(n) o(g(n))
Big-omega
t(n) (g(n))
Big-omega
t(n) (g(n))
Small-omega
t(n) (g(n))
Big-theta
t(n) (g(n))
Big theta
t(n) (g(n))
10
Big theta
t(n) (g(n))
11
5n+20 O(10n)
12
Yes
No
No
nk
n
cn
Yes
No
No
nsinn
No
No
No
2n
2n/2
No
Yes
No
5 nlgc
clgn
Yes
Yes
Yes
Yes
Yes
Yes
1 ln2n
2
6 lg(n!) lg(nn)
2n (2n/2)
2n (2n/2)
13
Yes
No
No
nk
n
cn
Yes
No
No
nsinn
No
No
No
2n
2n/2
No
Yes
No
5 nlgc
clgn
Yes
Yes
Yes
Yes
Yes
Yes
1 ln2n
2
6 lg(n!) lg(nn)
n O(nsinn)
Design and Analysis of Algorithms Chapter 2.2
n (nsinn)
14
c>0
15
logbn (logcn)
Design and Analysis of Algorithms Chapter 2.2
16
2n vs. 2n/2
2n-1 vs. 2n
log2n vs. n
17
LHpitals rule
If
Then
lim
n
t(n)
g(n) =
lim t (n)
n g (n)
18
Yes
No
No
nk
n
cn
Yes
No
No
nsinn
No
No
No
2n
2n/2
No
Yes
No
5 nlgc
clgn
Yes
Yes
Yes
Yes
Yes
Yes
1 ln2n
2
6 lg(n!) lg(nn)
19
Stirlings formula
n n
n! 2n ( )
e
Design and Analysis of Algorithms Chapter 2.2
20
n! v.s. nn
lg(n!) v.s. lg(nn)
21
22
n! o(nn)
lg(n!) v.s. lg(nn)
lg(n!) (lg(nn))
23
Special attention
n! o(nn)
However,
lg(n!) o(lg(nn))
lg(n!) (lg(nn))
sinn (1/2)
n1/2 (nsinn)
24
Transitivity:
f(n) = (g(n)) && g(n) = (h(n)) f(n) = (h(n))
f(n) = O(g(n)) && g(n) = O(h(n)) f(n) = O(h(n))
f(n) = (g(n)) && g(n) = (h(n)) f(n) = (h(n))
25
Transitivity:
f(n) = (g(n)) && g(n) = (h(n)) f(n) = (h(n))
f(n) = O(g(n)) && g(n) = O(h(n)) f(n) = O(h(n))
f(n) = (g(n)) && g(n) = (h(n)) f(n) = (h(n))
26
In-Class Exercises
b. n(n+1)/2 O(n2)
d. n(n+1)/2 (n)
27
Announcement
28
In-Class Exercises
b.
10n 2 7 n 3
c. 2nlg(n+2)2 + (n+2)2lg(n/2)
d. 2n+1 + 3n-1
e. log2n
Design and Analysis of Algorithms Chapter 2.2
29