Upcoming SlideShare
Loading in …5
×

# List of Software V1 00

1,183 views
1,149 views

Published on

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

No Downloads
Views
Total views
1,183
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
21
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

### List of Software V1 00

1. 1. Theoretical Computer Science Cheat Sheet Deﬁnitions Series iﬀ ∃ positive c, n0 such that f (n) = O(g(n)) n n n n2 (n + 1)2 n(n + 1) n(n + 1)(2n + 1) 0 ≤ f (n) ≤ cg(n) ∀n ≥ n0 . i2 = i3 = i= , , . 2 6 4 i=1 i=1 i=1 iﬀ ∃ positive c, n0 such that f (n) = Ω(g(n)) In general: f (n) ≥ cg(n) ≥ 0 ∀n ≥ n0 . n n 1 (n + 1)m+1 − 1 − (i + 1)m+1 − im+1 − (m + 1)im im = f (n) = Θ(g(n)) iﬀ f (n) = O(g(n)) and m+1 i=1 i=1 f (n) = Ω(g(n)). n−1 m 1 m+1 im = Bk nm+1−k . f (n) = o(g(n)) iﬀ limn→∞ f (n)/g(n) = 0. m+1 k i=1 k=0 iﬀ ∀ > 0, ∃n0 such that lim an = a Geometric series: n→∞ |an − a| < , ∀n ≥ n0 . ∞ ∞ n cn+1 − 1 1 c |c| < 1, ci = ci = ci = , c = 1, , , least b ∈ R such that b ≥ s, sup S c−1 1−c 1−c ∀s ∈ S. i=0 i=0 i=1 ∞ n ncn+2 − (n + 1)cn+1 + c c greatest b ∈ R such that b ≤ |c| < 1. ici = ici = inf S , c = 1, , (c − 1)2 (1 − c)2 s, ∀s ∈ S. i=0 i=0 Harmonic series: lim inf{ai | i ≥ n, i ∈ N}. lim inf an n n n(n − 1) 1 n(n + 1) n→∞ n→∞ Hn − Hn = , iHi = . lim sup{ai | i ≥ n, i ∈ N}. i 2 4 lim sup an i=1 i=1 n→∞ n→∞ n n i n+1 1 n Hi = (n + 1)Hn − n, Hn+1 − Combinations: Size k sub- Hi = . k m m+1 m+1 sets of a size n set. i=1 i=1 n n Stirling numbers (1st kind): n n! n n n 1. 2. 3. k = 2n , = , = , Arrangements of an n ele- (n − k)!k! n−k k k k k=0 ment set into k cycles. n n−1 n−1 n−1 n n 4. 5. = , = + , n k k−1 k−1 Stirling numbers (2nd kind): k k k k Partitions of an n element n n−k n m n r+k r+n+1 6. 7. = , = , set into k non-empty sets. m−k m k k k n k=0 n 1st order Eulerian numbers: n n k n+1 r s r+s k 8. 9. = , = , Permutations π1 π2 . . . πn on n−k m m+1 k n {1, 2, . . . , n} with k ascents. k=0 k=0 k−n−1 n n n 10. 11. k n = (−1) , = = 1, 2nd order Eulerian numbers. k k 1 n k Cn Catalan Numbers: Binary n−1 n−1 n n 12. = 2n−1 − 1, 13. =k + , trees with n + 1 vertices. k−1 2 k k n n n n n 14. = (n − 1)!, 15. = (n − 1)!Hn−1 , 16. 17. ≥ = 1, , 1 2 n k k n n−1 n−1 n n n n n 1 2n 18. = (n − 1) 19. 20. 21. Cn = + , = = , = n!, , k−1 n−1 n−1 k k 2 k n+1 n k=0 n−1 n−1 n n n n n 22. 23. 24. + (n − k) = = 1, = , = (k + 1) , n−1 n−1−k k−1 0 k k k 0 n n n+1 1 if k = 0, 25. 26. = 2n − n − 1, 27. = 3n − (n + 1)2n + = , k 1 2 2 0 otherwise n m n n x+k n n+1 n n k 28. 29. (m + 1 − k)n (−1)k , 30. m! xn = , = = , n−m k n m k m k k=0 k=0 k=0 n n−k n n n n 31. 32. 33. (−1)n−k−m k!, = = 1, = 0 for n = 0, m k m 0 n k=0 n n−1 n−1 (2n)n n n 34. + (2n − 1 − k) 35. = (k + 1) , = , k−1 2n k k k k=0 n n x+n−1−k x n n+1 n k k 36. 37. (m + 1)n−k , = , = = x−n k 2n m+1 k m m k=0 k k=0
2. 2. Theoretical Computer Science Cheat Sheet Identities Cont. Trees n n n Every tree with n n+1 n k k n−k 1k x n x+k 38. 39. = = n = n! , = , vertices has n − 1 x−n m+1 k m m k! m k 2n k k=0 k=0 k=0 edges. n n k+1 n n+1 k 40. 41. (−1)n−k , (−1)m−k , = = Kraft inequal- m k m+1 m k+1 m k k ity: If the depths m m m+n+1 n+k m+n+1 n+k of the leaves of 42. 43. = k , = k(n + k) , m k m k a binary tree are k=0 k=0 d1 , . . . , dn : n n+1 k n n+1 k 44. 45. (n − m)! for n ≥ m, (−1)m−k , (−1)m−k , = = n m k+1 m m k+1 m 2−di ≤ 1, k k m−n m−n n m+n m+k n m+n m+k i=1 46. 47. = , = , n−m n−m m+k n+k k m+k n+k k and equality holds k k n−k n−k only if every in- n +m k n n +m k n 48. 49. = , = . ternal node has 2 +m m k +m m k k k sons. Recurrences Master method: Generating functions: 1 T (n) − 3T (n/2) = n a ≥ 1, b > 1 T (n) = aT (n/b) + f (n), 1. Multiply both sides of the equa- tion by xi . 3 T (n/2) − 3T (n/4) = n/2 If ∃ > 0 such that f (n) = O(nlogb a− ) 2. Sum both sides over all i for . . . then . . . . . . which the equation is valid. T (n) = Θ(nlogb a ). 3log2 n−1 T (2) − 3T (1) = 2 3. Choose a generating function ∞ If f (n) = Θ(nlogb a ) then G(x). Usually G(x) = i=0 xi gi . T (n) = Θ(nlogb a log2 n). Let m = log2 n. Summing the left side 3. Rewrite the equation in terms of we get T (n) − 3m T (1) = T (n) − 3m = the generating function G(x). If ∃ > 0 such that f (n) = Ω(nlogb a+ ), T (n) − nk where k = log2 3 ≈ 1.58496. 4. Solve for G(x). and ∃c < 1 such that af (n/b) ≤ cf (n) Summing the right side we get 5. The coeﬃcient of xi in G(x) is gi . for large n, then m−1 m−1 ni Example: 3i 3 =n . T (n) = Θ(f (n)). 2 2i gi+1 = 2gi + 1, g0 = 0. i=0 i=0 Substitution (example): Consider the Let c = 3 . Then we have Multiply and sum: following recurrence 2 gi+1 xi = 2gi xi + xi . i m−1 Ti+1 = 22 · Ti2 , T1 = 2. c −1m i n c =n i≥0 i≥0 i≥0 c−1 Note that Ti is always a power of two. i=0 We choose G(x) = i≥0 xi gi . Rewrite = 2n(clog2 n − 1) Let ti = log2 Ti . Then we have in terms of G(x): ti+1 = 2i + 2ti , t1 = 1. = 2n(c(k−1) logc n − 1) G(x) − g0 xi . = 2G(x) + Let ui = ti /2i . Dividing both sides of x = 2nk − 2n, i≥0 the previous equation by 2i+1 we get and so T (n) = 3n − 2n. Full history re- 2i k Simplify: ti+1 ti = i+1 + i . G(x) 1 currences can often be changed to limited i+1 2 2 2 = 2G(x) + . 1−x x history ones (example): Consider Substituting we ﬁnd i−1 ui+1 = 1 + ui , u1 = 1 , Solve for G(x): 2 2 Ti = 1 + Tj , T0 = 1. x G(x) = . (1 − x)(1 − 2x) which is simply ui = i/2. So we ﬁnd j=0 i−1 that Ti has the closed form Ti = 2i2 . Note that Expand this using partial fractions: i Summing factors (example): Consider 2 1 − Ti+1 = 1 + Tj . G(x) = x the following recurrence 1 − 2x 1 − x   j=0 T (n) = 3T (n/2) + n, T (1) = 1. Subtracting we ﬁnd = x 2 xi  2i xi − Rewrite so that all terms involving T i i−1 are on the left side Ti+1 − Ti = 1 + Tj − 1 − i≥0 i≥0 Tj T (n) − 3T (n/2) = n. − 1)x i+1 i+1 j=0 j=0 = (2 . = Ti . Now expand the recurrence, and choose i≥0 a factor which makes the left side “tele- So gi = 2i − 1. And so Ti+1 = 2Ti = 2i+1 . scope”
3. 3. Theoretical Computer Science Cheat Sheet √ √ 1+ 5 1− 5 ˆ π ≈ 3.14159, e ≈ 2.71828, γ ≈ 0.57721, ≈ 1.61803, ≈ −.61803 φ= φ= 2 2 2i i pi General Probability Continuous distributions: If 1 2 2 Bernoulli Numbers (Bi = 0, odd i = 1): b 1 1 1 −2, − 30 , 2 4 3 B0 = 1, B1 = B2 = 6, B4 = Pr[a < X < b] = p(x) dx, 1 1 5 B6 = 42 , B8 = − 30 , B10 = 66 . 3 8 5 a then p is the probability density function of Change of base, quadratic formula: 4 16 7 √ X. If −b ± b2 − 4ac loga x 5 32 11 Pr[X < a] = P (a), logb x = , . loga b 2a 6 64 13 then P is the distribution function of X. If Euler’s number e: 7 128 17 P and p both exist then 1 1 1 1 + 24 + 120 + · · · e=1+ + a 8 256 19 2 6 P (a) = p(x) dx. xn = ex . 9 512 23 −∞ lim 1 + n n→∞ Expectation: If X is discrete 10 1,024 29 1n 1 n+1 1+ n <e< 1+ n . E[g(X)] = g(x) Pr[X = x]. 11 2,048 31 e 11e 1 1n x =e− −O 1+ + . 12 4,096 37 2 n3 n 2n 24n If X continuous then ∞ ∞ 13 8,192 41 Harmonic numbers: E[g(X)] = g(x)p(x) dx = g(x) dP (x). 14 16,384 43 1, 3 , 11 , 25 , 137 , 49 , 363 , 761 , 7129 , . . . −∞ −∞ 2 6 12 60 20 140 280 2520 15 32,768 47 Variance, standard deviation: VAR[X] = E[X 2 ] − E[X]2 , 16 65,536 53 ln n < Hn < ln n + 1, 17 131,072 59 1 σ = VAR[X]. Hn = ln n + γ + O . n 18 262,144 61 For events A and B: Pr[A ∨ B] = Pr[A] + Pr[B] − Pr[A ∧ B] Factorial, Stirling’s approximation: 19 524,288 67 Pr[A ∧ B] = Pr[A] · Pr[B], ... 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 20 1,048,576 71 iﬀ A and B are independent. 21 2,097,152 73 √ n n 1 Pr[A ∧ B] n! = 2πn 1+Θ . 22 4,194,304 79 e n Pr[A|B] = Pr[B] 23 8,388,608 83 Ackermann’s function and inverse:  For random variables X and Y : 24 16,777,216 89  2j i=1 E[X · Y ] = E[X] · E[Y ], a(i, j) = a(i − 1, 2) j=1 25 33,554,432 97  a(i − 1, a(i, j − 1)) i, j ≥ 2 if X and Y are independent. 26 67,108,864 101 E[X + Y ] = E[X] + E[Y ], α(i) = min{j | a(j, j) ≥ i}. 27 134,217,728 103 E[cX] = c E[X]. Binomial distribution: 28 268,435,456 107 Bayes’ theorem: n k n−k 29 536,870,912 109 q = 1 − p, Pr[X = k] = pq , Pr[B|Ai ] Pr[Ai ] k Pr[Ai |B] = n . 30 1,073,741,824 113 j=1 Pr[Aj ] Pr[B|Aj ] n n k n−k 31 2,147,483,648 127 E[X] = k pq = np. Inclusion-exclusion: k 32 4,294,967,296 131 n n k=1 Pr Xi = Pr[Xi ] + Poisson distribution: Pascal’s Triangle e−λ λk i=1 i=1 1 Pr[X = k] = , E[X] = λ. n k k! (−1)k+1 Pr Xij . 11 Normal (Gaussian) distribution: ii <···<ik j=1 k=2 121 1 2 2 e−(x−µ) /2σ , E[X] = µ. p(x) = √ Moment inequalities: 1331 2πσ 1 Pr |X| ≥ λ E[X] ≤ The “coupon collector”: We are given a , 14641 λ random coupon each day, and there are n 1 5 10 10 5 1 1 Pr X − E[X] ≥ λ · σ ≤ diﬀerent types of coupons. The distribu- . λ2 1 6 15 20 15 6 1 tion of coupons is uniform. The expected Geometric distribution: 1 7 21 35 35 21 7 1 number of days to pass before we to col- q = 1 − p, Pr[X = k] = pq k−1 , lect all n types is 1 8 28 56 70 56 28 8 1 ∞ 1 nHn . 1 9 36 84 126 126 84 36 9 1 kpq k−1 = E[X] = . p 1 10 45 120 210 252 210 120 45 10 1 k=1
4. 4. Theoretical Computer Science Cheat Sheet Trigonometry Matrices More Trig. C Multiplication: n (0,1) C = A · B, ci,j = ai,k bk,j . a b h b (cos θ, sin θ) k=1 C θ Determinants: det A = 0 iﬀ A is non-singular. A (-1,0) (1,0) A c B det A · B = det A · det B, Law of cosines: c a c2 = a2 +b2 −2ab cos C. n (0,-1) det A = sign(π)ai,π(i) . B Area: π i=1 Pythagorean theorem: 2 × 2 and 3 × 3 determinant: C 2 = A2 + B 2 . A = 1 hc, 2 ab = ad − bc, = 1 ab sin C, Deﬁnitions: cd 2 sin a = A/C, cos a = B/C, c2 sin A sin B ab c = . b c ac ab csc a = C/A, sec a = C/B, −h 2 sin C f =g de +i e f df de sin a A cos a B Heron’s formula: gh i tan a = =, cot a = =. cos a B sin a A √ aei + bf g + cdh A = s · sa · sb · sc , = − ceg − f ha − ibd. Area, radius of inscribed circle: s = 1 (a + b + c), AB 1 Permanents: 2 AB, . 2 A+B+C n sa = s − a, ai,π(i) . perm A = Identities: sb = s − b, π i=1 1 1 sc = s − c. sin x = , cos x = , Hyperbolic Functions csc x sec x 1 More identities: Deﬁnitions: sin2 x + cos2 x = 1, tan x = , ex − e−x −x x 1 − cos x cot x e +e sin x = sinh x = , cosh x = , , 1 + tan2 x = sec2 x, 1 + cot2 x = csc2 x, 2 2 2 2 −x e −e x 1 tanh x = x , csch x = , 1 + cos x e + e−x −x , sin x = sin(π − x), π cos x = sinh x sin x = cos , 2 2 2 1 1 sech x = , coth x = . 1 − cos x cos x = − cos(π − x), −x , π cosh x tanh x tan x = cot 2 tan x = , 2 1 + cos x Identities: cot x = − cot(π − x), csc x = cot x − cot x, 1 − cos x 2 cosh2 x − sinh2 x = 1, tanh2 x + sech2 x = 1, = , sin x sin(x ± y) = sin x cos y ± cos x sin y, sin x coth2 x − csch2 x = 1, sinh(−x) = − sinh x, = , 1 + cos x cos(x ± y) = cos x cos y sin x sin y, tanh(−x) = − tanh x, cosh(−x) = cosh x, 1 + cos x tan x ± tan y cot x = , tan(x ± y) = 2 , 1 − cos x sinh(x + y) = sinh x cosh y + cosh x sinh y, 1 tan x tan y 1 + cos x cot x cot y 1 = , cot(x ± y) = cosh(x + y) = cosh x cosh y + sinh x sinh y, , sin x cot x ± cot y sin x 2 tan x = , sinh 2x = 2 sinh x cosh x, 1 − cos x sin 2x = 2 sin x cos x, sin 2x = , 1 + tan2 x eix − e−ix cosh 2x = cosh2 x + sinh2 x, cos 2x = cos2 x − sin2 x, cos 2x = 2 cos2 x − 1, sin x = , 2i cosh x − sinh x = e−x , 1 − tan2 x cosh x + sinh x = ex , eix + e−ix cos 2x = 1 − 2 sin2 x, cos 2x = , 1 + tan2 x cos x = , n ∈ Z, (cosh x + sinh x)n = cosh nx + sinh nx, 2 cot2 x − 1 eix − e−ix 2 tan x tan x = −i ix 2 sinh2 x 2 cosh2 x tan 2x = 2, cot 2x = , , = cosh x − 1, = cosh x + 1. 1 − tan x e + e−ix 2 cot x 2 2 e2ix − 1 sin(x + y) sin(x − y) = sin2 x − sin2 y, = −i 2ix , θ sin θ cos θ tan θ . . . in mathematics e +1 cos(x + y) cos(x − y) = cos2 x − sin2 y. you don’t under- sinh ix 0 0 1 0 sin x = , √ √ stand things, you 1 3 3 i π Euler’s equation: 6 2 2 3 just get used to √ √ = −1. cos x = cosh ix, eix = cos x + i sin x, iπ e 2 2 π them. 1 4 2 2 √ tanh ix √ – J. von Neumann v2.02 c 1994 by Steve Seiden 3 1 tan x = . π 3 i 3 2 2 sseiden@acm.org ∞ π 1 0 2 http://www.csc.lsu.edu/~seiden
5. 5. Theoretical Computer Science Cheat Sheet Number Theory Graph Theory Notation: Deﬁnitions: The Chinese remainder theorem: There ex- ists a number C such that: E(G) Edge set Loop An edge connecting a ver- V (G) Vertex set tex to itself. C ≡ r1 mod m1 c(G) Number of components Directed Each edge has a direction. .. . G[S] Induced subgraph Simple Graph with no loops or .. . .. . deg(v) Degree of v multi-edges. C ≡ rn mod mn ∆(G) Maximum degree Walk A sequence v0 e1 v1 . . . e v . δ(G) Minimum degree Trail A walk with distinct edges. if mi and mj are relatively prime for i = j. χ(G) Chromatic number Path A trail with distinct Euler’s function: φ(x) is the number of χE (G) Edge chromatic number vertices. positive integers less than x relatively Gc Complement graph n Connected A graph where there exists prime to x. If i=1 pei is the prime fac- i Kn Complete graph a path between any two torization of x then Kn1 ,n2 Complete bipartite graph n vertices. pi i −1 (pi − 1). e r(k, ) Ramsey number φ(x) = Component A maximal connected i=1 subgraph. Geometry Euler’s theorem: If a and b are relatively Tree A connected acyclic graph. Projective coordinates: triples prime then Free tree A tree with no root. (x, y, z), not all x, y and z zero. 1 ≡ aφ(b) mod b. DAG Directed acyclic graph. (x, y, z) = (cx, cy, cz) ∀c = 0. Eulerian Graph with a trail visiting Fermat’s theorem: Cartesian Projective each edge exactly once. 1 ≡ ap−1 mod p. Hamiltonian Graph with a cycle visiting (x, y) (x, y, 1) The Euclidean algorithm: if a > b are in- y = mx + b (m, −1, b) each vertex exactly once. tegers then (1, 0, −c) Cut A set of edges whose re- x=c gcd(a, b) = gcd(a mod b, b). moval increases the num- Distance formula, Lp and L∞ ber of components. metric: n If i=1 pei is the prime factorization of x i Cut-set A minimal cut. (x1 − x0 )2 + (y1 − y0 )2 , then pi i +1 − 1 n Cut edge A size 1 cut. e 1/p |x1 − x0 |p + |y1 − y0 |p , S(x) = d= . k-Connected A graph connected with pi − 1 the removal of any k − 1 p 1/p i=1 d|x lim |x1 − x0 |p + |y1 − y0 | . vertices. p→∞ Perfect Numbers: x is an even perfect num- ∀S ⊆ V, S = ∅ we have Area of triangle (x0 , y0 ), (x1 , y1 ) k-Tough ber iﬀ x = 2n−1 (2n −1) and 2n −1 is prime. k · c(G − S) ≤ |S|. and (x2 , y2 ): Wilson’s theorem: n is a prime iﬀ x1 − x0 y1 − y0 (n − 1)! ≡ −1 mod n. k-Regular A graph where all vertices 1 2 abs x − x . 0 y2 − y0 have degree k. 2 M¨bius  o inversion: k-Factor A k-regular spanning Angle formed by three points: 1 if i = 1.  subgraph. 0 if i is not square-free. µ(i) = Matching A set of edges, no two of  (−1)r if i is the product of (x2 , y2 )  which are adjacent. r distinct primes. 2 Clique A set of vertices, all of If θ which are adjacent. G(a) = F (d), (x1 , y1 ) (0, 0) 1 Ind. set A set of vertices, none of (x1 , y1 ) · (x2 , y2 ) d|a which are adjacent. cos θ = . then Vertex cover A set of vertices which 12 a F (a) = µ(d)G . Line through two points (x0 , y0 ) cover all edges. d and (x1 , y1 ): d|a Planar graph A graph which can be em- beded in the plane. xy1 Prime numbers: ln ln n Plane graph An embedding of a planar x0 y0 1 = 0. pn = n ln n + n ln ln n − n + n graph. ln n x1 y1 1 n Area of circle, volume of sphere: +O , deg(v) = 2m. ln n A = πr2 , V = 4 πr3 . 3 v∈V n n 2!n If G is planar then n − m + f = 2, so π(n) = + + ln n (ln n)2 (ln n)3 If I have seen farther than others, f ≤ 2n − 4, m ≤ 3n − 6. it is because I have stood on the n +O . Any planar graph has a vertex with de- shoulders of giants. (ln n)4 gree ≤ 5. – Issac Newton