"Big-Oh", "Big-Omega", and "Big-Theta": Properties and Rules
"Big-Oh", "Big-Omega", and "Big-Theta": Properties and Rules
"Big-Oh", "Big-Omega", and "Big-Theta": Properties and Rules
1 / 14
Outline Big-Oh rules Examples
1 Big-Oh rules
Scaling
Transitivity
Rule of sums
Rule of products
Limit rule
2 Examples
2 / 14
Outline Big-Oh rules Examples
Scaling
Big-Oh: Scaling
The proof: cf (n) < (c + ε)f (n) holds for all n > 0 and ε > 0.
• Constant factors are ignored.
• Only the powers and functions of n should be exploited
It is this ignoring of constant factors that motivates for such a
notation! In particular, f is O(f ).
50n ∈ O(n) 0.05n ∈ O(n)
Examples:
50, 000, 000n ∈ O(n) 0.0000005n ∈ O(n)
3 / 14
Outline Big-Oh rules Examples
Scaling
Big-Oh: Scaling
The proof: cf (n) < (c + ε)f (n) holds for all n > 0 and ε > 0.
• Constant factors are ignored.
• Only the powers and functions of n should be exploited
It is this ignoring of constant factors that motivates for such a
notation! In particular, f is O(f ).
50n ∈ O(n) 0.05n ∈ O(n)
Examples:
50, 000, 000n ∈ O(n) 0.0000005n ∈ O(n)
3 / 14
Outline Big-Oh rules Examples
Scaling
Big-Oh: Scaling
The proof: cf (n) < (c + ε)f (n) holds for all n > 0 and ε > 0.
• Constant factors are ignored.
• Only the powers and functions of n should be exploited
It is this ignoring of constant factors that motivates for such a
notation! In particular, f is O(f ).
50n ∈ O(n) 0.05n ∈ O(n)
Examples:
50, 000, 000n ∈ O(n) 0.0000005n ∈ O(n)
3 / 14
Outline Big-Oh rules Examples
Scaling
Big-Oh: Scaling
The proof: cf (n) < (c + ε)f (n) holds for all n > 0 and ε > 0.
• Constant factors are ignored.
• Only the powers and functions of n should be exploited
It is this ignoring of constant factors that motivates for such a
notation! In particular, f is O(f ).
50n ∈ O(n) 0.05n ∈ O(n)
Examples:
50, 000, 000n ∈ O(n) 0.0000005n ∈ O(n)
3 / 14
Outline Big-Oh rules Examples
Transitivity
Big-Oh: Transitivity
The proof:
◦ h(n) ≤ c1 g(n) for n > n1 ; c1 > 0, because h ∈ O(g).
• g(n) ≤ c2 f (n) for n > n2 ; c2 > 0, because g ∈ O(f ).
→ Substituting the second inequality (•) into the first inequality
(◦) leads to the inequality
4 / 14
Outline Big-Oh rules Examples
Transitivity
Big-Oh: Transitivity
The proof:
◦ h(n) ≤ c1 g(n) for n > n1 ; c1 > 0, because h ∈ O(g).
• g(n) ≤ c2 f (n) for n > n2 ; c2 > 0, because g ∈ O(f ).
→ Substituting the second inequality (•) into the first inequality
(◦) leads to the inequality
4 / 14
Outline Big-Oh rules Examples
Transitivity
Big-Oh: Transitivity
Examples:
• If h ∈ O(g) and g ∈ O(n2 ), then h ∈ O(n2 ).
5 / 14
Outline Big-Oh rules Examples
Transitivity
Big-Oh: Transitivity
Examples:
• If h ∈ O(g) and g ∈ O(n2 ), then h ∈ O(n2 ).
5 / 14
Outline Big-Oh rules Examples
Transitivity
Big-Oh: Transitivity
Examples:
• If h ∈ O(g) and g ∈ O(n2 ), then h ∈ O(n2 ).
5 / 14
Outline Big-Oh rules Examples
Transitivity
Big-Oh: Transitivity
Examples:
• If h ∈ O(g) and g ∈ O(n2 ), then h ∈ O(n2 ).
5 / 14
Outline Big-Oh rules Examples
Rule of sums
The proof:
◦ g1 (n) ≤ c1 f1 (n) for n > n1 , because g1 ∈ O(f1 ).
• g2 (n) ≤ c2 f2 (n) for n > n2 , because g2 ∈ O(f2 ).
→ Summing the inequalities (◦) and (•) leads to the inequality
g1 (n) + g2 (n) ≤ c1 f1 (n) + c2 f2 (n)
≤ max{c1 , c2 } (f1 (n) + f2 (n))
≤ 2 · max{c1 , c2 } · max {f1 (n), f2 (n)}
| {z }
c; c>0
Rule of sums
The proof:
◦ g1 (n) ≤ c1 f1 (n) for n > n1 , because g1 ∈ O(f1 ).
• g2 (n) ≤ c2 f2 (n) for n > n2 , because g2 ∈ O(f2 ).
→ Summing the inequalities (◦) and (•) leads to the inequality
g1 (n) + g2 (n) ≤ c1 f1 (n) + c2 f2 (n)
≤ max{c1 , c2 } (f1 (n) + f2 (n))
≤ 2 · max{c1 , c2 } · max {f1 (n), f2 (n)}
| {z }
c; c>0
Rule of sums
The proof:
◦ g1 (n) ≤ c1 f1 (n) for n > n1 , because g1 ∈ O(f1 ).
• g2 (n) ≤ c2 f2 (n) for n > n2 , because g2 ∈ O(f2 ).
→ Summing the inequalities (◦) and (•) leads to the inequality
g1 (n) + g2 (n) ≤ c1 f1 (n) + c2 f2 (n)
≤ max{c1 , c2 } (f1 (n) + f2 (n))
≤ 2 · max{c1 , c2 } · max {f1 (n), f2 (n)}
| {z }
c; c>0
Rule of sums
Examples:
7 / 14
Outline Big-Oh rules Examples
Rule of sums
max{f1 , f2 }
g1 + g2
f1 (n)
g2 (n) = O(f2 (n))
8 / 14
Outline Big-Oh rules Examples
Rule of products
The proof:
◦ g1 (n) ≤ c1 f1 (n) for n > n1 , because g1 ∈ O(f1 ).
• g2 (n) ≤ c2 f2 (n) for n > n2 , because g2 ∈ O(f2 ).
→ Multiplying the inequalities (◦) and (•) leads to the inequality
9 / 14
Outline Big-Oh rules Examples
Rule of products
The proof:
◦ g1 (n) ≤ c1 f1 (n) for n > n1 , because g1 ∈ O(f1 ).
• g2 (n) ≤ c2 f2 (n) for n > n2 , because g2 ∈ O(f2 ).
→ Multiplying the inequalities (◦) and (•) leads to the inequality
9 / 14
Outline Big-Oh rules Examples
Rule of products
The proof:
◦ g1 (n) ≤ c1 f1 (n) for n > n1 , because g1 ∈ O(f1 ).
• g2 (n) ≤ c2 f2 (n) for n > n2 , because g2 ∈ O(f2 ).
→ Multiplying the inequalities (◦) and (•) leads to the inequality
9 / 14
Outline Big-Oh rules Examples
Rule of products
Examples:
• If h ∈ O(n) and g ∈ O(n2 ), then gh ∈ O(n3 ).
• If h ∈ O(log n) and g ∈ O(n), then gh ∈ O(n log n).
10 / 14
Outline Big-Oh rules Examples
Limit rule
When f and g are positive and differentiable functions for x > 0, but
lim f (x) = lim g(x) = ∞ or lim f (x) = lim g(x) = 0, the limit L
x→∞ x→∞ x→∞ x→∞
can be computed using the standard L’Hopital rule of calculus:
f (x) f 0 (x)
lim = lim 0
x→∞ g(x) x→∞ g (x)
dz(x)
where z 0 (x) ≡ dx denotes the first derivative of the function z(x).
11 / 14
Outline Big-Oh rules Examples
dxk d 2 xk
dn = kxk−1 ; dx2
= k(k − 1)xk−2 ; . . .
dk xk dk+1 xk
dxk
= k(k − 1) · · · 2 · 1 = k!; dxk+1
=0
12 / 14
Outline Big-Oh rules Examples
dxk d 2 xk
dn = kxk−1 ; dx2
= k(k − 1)xk−2 ; . . .
dk xk dk+1 xk
dxk
= k(k − 1) · · · 2 · 1 = k!; dxk+1
=0
12 / 14
Outline Big-Oh rules Examples
dxk d 2 xk
dn = kxk−1 ; dx2
= k(k − 1)xk−2 ; . . .
dk xk dk+1 xk
dxk
= k(k − 1) · · · 2 · 1 = k!; dxk+1
=0
12 / 14
Outline Big-Oh rules Examples
• Derivatives of g(x) = bx by x:
dbx d2 bx
dx = bx ln b; dx2
= bx (ln b)2 ; ...
dk bx dk+1 bx
dxk
= bx (ln b)k ; dxk+1
= bx (ln b)k+1
nk 0
lim = lim n =0
n→∞ bn n→∞ b (ln b)k+1
for b > 1, proving that nk ∈ O(bn ) for all b > 1, n > 1, and
k ≥ 0.
13 / 14
Outline Big-Oh rules Examples
• Derivatives of g(x) = bx by x:
dbx d2 bx
dx = bx ln b; dx2
= bx (ln b)2 ; ...
dk bx dk+1 bx
dxk
= bx (ln b)k ; dxk+1
= bx (ln b)k+1
nk 0
lim = lim n =0
n→∞ bn n→∞ b (ln b)k+1
for b > 1, proving that nk ∈ O(bn ) for all b > 1, n > 1, and
k ≥ 0.
13 / 14
Outline Big-Oh rules Examples
The proof:
k
• The first derivative of f (x) = xk by x is dx
dx = kx
k−1 .
14 / 14
Outline Big-Oh rules Examples
The proof:
k
• The first derivative of f (x) = xk by x is dx
dx = kx
k−1 .
14 / 14
Outline Big-Oh rules Examples
The proof:
k
• The first derivative of f (x) = xk by x is dx
dx = kx
k−1 .
14 / 14
Outline Big-Oh rules Examples
The proof:
k
• The first derivative of f (x) = xk by x is dx
dx = kx
k−1 .
14 / 14
Outline Big-Oh rules Examples
The proof:
k
• The first derivative of f (x) = xk by x is dx
dx = kx
k−1 .
14 / 14
Outline Big-Oh rules Examples
The proof:
k
• The first derivative of f (x) = xk by x is dx
dx = kx
k−1 .
14 / 14