Cheatsheet

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Cheat Sheet for 2320 Last updated: 1/17/2019

1 2 3 4
(𝑥 𝑎 )𝑏 = (𝑥 𝑏 )𝑎 lg(𝑥 𝑎 ) = 𝑎(lg 𝑥)
log a x 
log b x a logb x
x logb a
𝑥 𝑎 ∗ 𝑥 𝑏 = 𝑥 𝑎+𝑏 lg(𝑥𝑦) = 𝑙𝑔𝑥 + 𝑙𝑔𝑦
log b a
𝑛(𝑛+1)
a) Summation of consecutive values: 1+2+3+ … +n = ∑𝑛𝑘=1 𝑘 =
2
𝑛(𝑛+1)(2𝑛+1)
b) Summation of squares: 1+2 +3 + … +n = ∑𝑛𝑘=1 𝑘 2 =
2 2 2
6
n
(a1  an ) n
c) Summation of Arithmetic series (where ai  a1  (i  1)d ): a
i 1
i n
2
 [2a1  (n  1)d ]
2
2 n
d) Summation of Geometric Series: 1+x+x + … x
0<x<1 x>1 x=1


n1
1
n
1 1k n  1
 x k k 0 x k 
 x
k 0 x k 
n n
k 0
k 0
1 x x 1
n 1 1
Harmonic series: ln( n  1)   

e)
k 1
 ln n  1 e2)
k 0
 e  2.718281...  2.72
k k!
x
k 0 kxk  (1  x)2 , for | x | 1 (CLRS pg.1148)

f)

g) Approximation by integrals (CLRS, 1154):


f(x) monotonically increasing: 𝑥 ≤ 𝑦 ⇒ 𝑓(𝑥) ≤ 𝑓(𝑦) f(x) is monotonically decreasing: 𝑥 ≤ 𝑦 ⇒ 𝑓(𝑥) ≥ 𝑓(𝑦)

𝑛 𝑛+1 𝑛+1 𝑛
∫𝑚−1 𝑓(𝑥)𝑑𝑥 ≤ ∑𝑛𝑘=𝑚 𝑓(𝑘) ≤ ∫𝑚 𝑓(𝑥)𝑑𝑥 ∫𝑚 𝑓(𝑥)𝑑𝑥 ≤ ∑𝑛𝑘=𝑚 𝑓(𝑘) ≤ ∫𝑚−1 𝑓(𝑥)𝑑𝑥

h) Radix sort (optimal r): r = min{b, floor(lg N)}


i) Master Theorem (CLRS): Let a ≥ 1 and b > 1, let f(n) be a function, and let T(n) be defined on the nonnegative integers by the
recurrence: T(n) = aT(n/b) + f(n) , where we interpret n/b to mean either n / b or n / b . Then T(n) has the following
asymptotic bounds:
logb a
1. If f(n) = O(𝑛(𝑙𝑜𝑔𝑏 𝑎)−𝜀 ) for some constant ε > 0, then T(n) = Θ( n ).
logb a logb a
2. If f(n) = Θ( n ), then T(n) = Θ( n lg n ).
(𝑙𝑜𝑔𝑏 𝑎)+𝜀
3. If f(n) = Ω(𝑛 ), for some constant ε > 0, and if af(n/b) ≤ cf(n) for some constant c < 1 and all sufficiently large
n, then T(n) = Θ( f (n) ).
𝑓 ′(𝑛)
j) 𝐿′ 𝐻𝑜𝑠𝑝𝑖𝑡𝑎𝑙 𝑟𝑢𝑙𝑒: 𝑖𝑓 lim𝑛→∞ 𝑓(𝑛) 𝑎𝑛𝑑 lim𝑛→∞ 𝑔(𝑛) 𝑎𝑟𝑒 𝑏𝑜𝑡ℎ 0 𝑜𝑟 ± ∞, 𝑎𝑛𝑑 𝑖𝑓 lim𝑛→∞ 𝑖𝑠 𝑎 𝑐𝑜𝑛𝑠𝑡𝑎𝑛𝑡 𝑜𝑟 ± ∞,
𝑔′ (𝑛)
𝑓(𝑛) 𝑓 ′ (𝑛)
𝑡ℎ𝑒𝑛 lim𝑛→∞ = lim𝑛→∞ .
𝑔(𝑛) 𝑔′ (𝑛)

k) Notation Limit theorem Definition with constants


1 𝑓(𝑛) = Θ(𝑔(𝑛)) 𝑓(𝑛) There exist positive constants c0 , c1 and n0 s.t.:
lim𝑛→∞ =𝑐≠0
𝑔(𝑛)
c0 g(n) ≤ f(n) ≤ c1 g(n) for all n ≥ n0
2 𝑓(𝑛) = 𝑂(𝑔(𝑛)) 𝑓(𝑛) There exist positive constants c1 and n0 such that:
lim𝑛→∞ = 0 𝑜𝑟 𝑐
𝑔(𝑛)
f(n) ≤ c1 g(n) for all n ≥ n0
3 𝑓(𝑛) = Ω(𝑔(𝑛)) 𝒈(𝑛) There exist positive constants c0 and n0 such that:
lim = 0 𝑜𝑟 𝑐
𝑛→∞ 𝒇(𝑛) c0 g(n) ≤ f(n) for all n ≥ n0
4 𝑓(𝑛) = 𝑜(𝑔(𝑛)) 𝑓(𝑛) For any positive constant c1 , there exists n0 s.t.:
lim =0
𝑛→∞ 𝑔(𝑛) f(n) < c1 g(n) for all n ≥ n0
6 𝑓(𝑛) = 𝜔(𝑔(𝑛)) 𝑔(𝑛) For any positive constant c0 , there exist n0 s.t.:
lim =0
𝑛→∞ 𝑓(𝑛) c0 g(n) < f(n) for all n ≥ n0

You might also like