cheatACM

# cheatACM - Theoretical Computer Science Cheat Sheet f (n) =...

This preview shows pages 1–3. Sign up to view the full content.

Theoretical Computer Science Cheat Sheet Definitions f(n) = O(g(n)) iff q positive c, no such that 0 _< f(n) _< cgCn) vn >_ no. = f~(g(n)) iff 3 positive c, no such that f(n) >_ co(m) >_ 0 Vn >_ no. iff = O(g(n)) and fCn) = n(g(n)). /(n) = o(g(n)) iff lin~_.~ f(n)Ig(n) = O. lim a.=a iff Ve 6 R, qn0 such that "-'= I~- - "I < e, Vn >_ n0. sup S least b 6 R such that b >_ s, Vs6S. infS greatest b 6 R such that b _< s, Vs 6S. liminfa, lirn_ inf{a, l i > n, i 6 N}. limsupa, lim sup{al [ i >__ n,i 6 N}. (~) Combinations: Size k sub- sets of a size n set. [~] Stifling numbers (lst kind): Arrangements of an n ele- ment set into k cycles. { ~. } Stirling numbers (2nd kind): Partitions of an n element set into k non-empty sets. ( ~ > " 1st order Eulerian numbers: Permutations 7r171"2_. . 71"r~ On {1, 2,. .., n} with k ascents. (( ~ >) 2nd order Eulerian numbers. C. Catlan Numbers: Binary trees with n + 1 vertices. Series i-- nCn2 +1)' ~-~i~: nCn+l)(2n6 +I) i=i i=1 In general: n ~--~ 13 _ n~-(" + 1) ~- ' 4 i=l Ei'~ rn+l (n+ -1- ((i + 11 "~+' i=1 = m 1 n--1 £( : ) i~t i,.,, _ 1 m 1 B~n,~+1_k. m~l "= k=O Geometric series: _ i,-+~ _ (-, + 1)i')] £ cn+l -- I £ I £ C c ~ -- c # 1, c i " c--l" = 1-c' c'= 1-c' c<l, /=O i=0 i=1 £icl = ncn+2--(n-I - 1)C n+l -I-c £ - C ,=o (c--1) = , cp1, ie'-- (1-c)"' c<1. i=0 Harmonic series: Hn=£ il, £ iHi -- n(n2 + 1) H,~ n(n 4- 1) i=I i=t £(:) co+,~( ,) Hi = \rn-b 1) Hr*+I -~- 1 " m /1 EHi = (n + 1)H, - n, i=1 1. (~) °' - (n -7=)~k~' , (:)=~(::~), o. (:)(:): (:)(:-~), k=o \m + I) 12. 2 = 2. £(:):~, 3. (:): (n) k=D D -- k ,. ~(,+~):(,÷o+1). ~ o o. £(;)(o:~)= ¢:I. {o} {o} =I. II. 1 = n 13. k = k k + k 1 : 1,. [~] :~n_x,,. ,o. [;] =~o_,~,~_,, 16. [:] =,, 17. [:]> {o} -- k ' k + 19. = = 20. = hi, 21. C. - ' n-I n-i ' n+l ' l;=o ,~.<o>:<o> <:> < ~ > <;> ~<~_1> ,<o_1> =i, 23. = 24. =(k+l +(n-k n-1 n--l-k ' k k I ' <o> ~1 ~f~__o, ~6. <~>__~_o ~, 2, <;> ~ (~) 25. k = 0 otherwise - : - (n+ 1)2" + 2 ' n ' ~: _ -- ' n--1 1 32. £ <<:>> ~2o,~_ 35. = 2" ' k=o 3°{. _-o} £ <<:>> (. +o_ 1_ ~)2o = 37. fn-I'11 n k 1)n_ k k 52

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Theoretical Computer Science Cheat Sheet Identities Cont. Trees [n+l]__~ [;](k) £[k] ~__o 1 [k] 38. Lm + lJ = n '~-j: = n! ~ , k=0 n k+l . i'" k, 40" {:}=~(k)(rn_l_a}l,- ) - 42. {rn+n-I-l} =£k{n+k} m k ' f----O "" 44. (:) = t,~{;::}[k](-l) "-k, 45. (n--m),(:) ,,. [.: o] _- £ ((:)):-+ k=o \ 2n ) 41. [:] :~[;:~](k)(-l)m-~, rn . k ' :~[;:l]{km}(-l) ""-t, forn>__m, 46. { 7rn}:~(:--;)(m-l-n'~[rn: k] 4T. [nTrn]---- rE(:--;)(:::){ re+k} n + kn+k) ' + k ' 48. {g:rn}(g~rn) =~t (k~.}{n~nk}(;) , 49. [,:rn]('~m) :~[~][n~k](;). Every tree with n vertices has n- 1 edges. Kraft inequal- ity: If the depths of the leaves of a binary tree are dl, - -., d.: fx E 2-a: <- 1, i=1 and equality holds only if every in- ternal node has 2 sons. Recurrences Master method: • T(n)=aT(n/b)+f(n), a>_ l,b> 1 If Be > 0 such that f(n) = O(n logb a-,) then T(n) = O(n l°gb "). If 1(n) = O(n ~°~ ~) then T(n) = O(n~°g' ° 1og~ n). If 3e > 0 such that = f](n l°gb a+,), and 3c < 1 such that af(n/b) <_ cf(n) for large n, then = ®(f(n)). Substitution (example): Consider the following recurrence T~+z=22'.T~, TI=2- Note that T/ is always a power of two. Let ti = log 2 T/. Then we have ti+l = 2 i + 2ti, t I = i. Let u~ = t;/2 i. Dividing both sides of the previous equation by 2 I+1 we get ti+t 2 i ti 2i+1 -- 2i+----- [ + 2i. Substituting we find Ui+I = 21- + Ui, U 1 = 12, which is simply u{ = i/2. So we find that T/has the closed form T~ = 2 {2~-' . Summing factors (example): Consider the following recurrence Ti = 3T.12 + n, Tl = n. Rewrite so that M1 terms involving T are on the left side Ti - 32',12 = n. Now expand the recurrence, and choose a factor which makes the left side "tele- scope" l(T(n) - aT(n/2) = n) 3(T(n/2) - 3T(n/4) = n/2) 31og, n-I (T(2) - 3T(1) = 2) 3log, n (T(1) - 0 = 1) Summing the left side we get T(n). Sum- ming the right side we get log 2 n n i E#- i=O c = .=~ and rn = loll 2~ n. Then we have (C m+l -- i'~ n~c~=n \ 7:T / = 2n(c.
This is the end of the preview. Sign up to access the rest of the document.

## cheatACM - Theoretical Computer Science Cheat Sheet f (n) =...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online