Professional Documents
Culture Documents
01 Intro 4 2 Asymptoticnotation2
01 Intro 4 2 Asymptoticnotation2
Big-O Notation
Daniel Kane
Department of Computer Science and Engineering
University of California, San Diego
Definition
f (n) = O(g (n)) (f is Big-O of g ) or f ⪯ g
if there exist constants N and c so that for
all n ≥ N, f (n) ≤ c · g (n).
Big-O Notation
Definition
f (n) = O(g (n)) (f is Big-O of g ) or f ⪯ g
if there exist constants N and c so that for
all n ≥ N, f (n) ≤ c · g (n).
Example
3n2 + 5n + 2 = O(n2) since if n ≥ 1,
3n2 + 5n + 2 ≤ 3n2 + 5n2 + 2n2 = 10n2.
Growth Rate
3n2 + 5n + 2 has the same growth rate as n2
10
9
8
7
6
5 3n2 +5n+2
4 n2
3
2
1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Using Big-O