Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Theoretical Computer Science Cheat Sheet - Advanced Data Structures | CS 6310, Study notes of Data Structures and Algorithms

Material Type: Notes; Professor: Gupta; Class: Adv Data Structures; Subject: Computer Science; University: Western Michigan University; Term: Fall 2004;

Typology: Study notes

Pre 2010

Uploaded on 07/28/2009

koofers-user-0q2
koofers-user-0q2 🇺🇸

10 documents

Partial preview of the text

Download Theoretical Computer Science Cheat Sheet - Advanced Data Structures | CS 6310 and more Study notes Data Structures and Algorithms in PDF only on Docsity! Theoretical Computer Science Cheat Sheet Denitions Series fn  Ogn i positive c n such that   fn  cgn n  n nX i i  nn  nX i i  nn  n  nX i i  nn   In general nX i im   m  n  m   nX i  i m  im  m  im nX i im   m  mX k  m   k  Bkn mk Geometric series nX i ci  cn   c  c   X i ci    c X i ci  c  c c   nX i ici  ncn  n cn  c c  c   X i ici  c   c c   Harmonic series Hn  nX i  i nX i iHi  nn  Hn  nn   nX i Hi  n  Hn  n nX i  i m  Hi   n  m   Hn   m     fn  gn i positive c n such that fn  cgn   n  n fn  gn i fn  Ogn and fn  gn fn  ogn i limn fngn   lim n an  a i   R n such thatjan  aj   n  n sup S least b  R such that b  s s  S inf S greatest b  R such that b  s s  S lim inf n an limn inffai j i  n i  Ng lim sup n an lim n supfai j i  n i  Ng n k  Combinations Size k sub sets of a size n set n k  Stirling numbers st kind Arrangements of an n ele ment set into k cycles   n k   n n  kk  nX k  n k   n   n k    n n k    n k   n k  n  k      n k    n  k    n  k      n m  m k    n k  n k m  k   X kn  r  k k    r  n  n   nX k  k m    n   m    nX k  r k  s n  k    r  s n    n k   k  k  n  k    n    n n     n  n     n k  k  n  k   n  k   n k Stirling numbers  nd kind Partitions of an n element set into k nonempty sets n k st order Eulerian numbers Permutations     n on f    ng with k ascents n k nd order Eulerian numbers Cn Catlan Numbers Binary trees with n  vertices  n    n   n   n  Hn  n n     n k    n k  n k   n  n  k   n  k      n n   n n     n    nX k n k   n  Cn   n   n n    n     n n       n k    n n  k    n k   k    n  k   n k  n  k       k   n  if k    otherwise   n    n  n    n   n  n  n   n    xn  nX k  n k  x k n     n m   mX k  n  k  m   knk   m  n m  nX k  n k  k nm    n m   nX k  n k  n k m  nkmk   n       n n    for n     n k   k    n   k    n  k  n  k     nX k  n k    nn n   x x n  nX k  n k   x n  k n    n  m    X k  n k  k m  nX k  k m m  nk Theoretical Computer Science Cheat Sheet Identities Cont Trees  n  m     X k n k  k m   nX k k m  nnk  n nX k  k k m    x x n   nX k  n k  x k n     n m  X k  n k  k   m   nk  n m   X k n   k    k m  mk   m  n   m  mX k k  n k k  m  n   m   mX k kn  k n k k    n m   X k  n  k   k m  mk  nm  n m   X k n  k    k m mk for n  m   n nm  X k  m  n m  k  m n n k  m  k k   n n m   X k  m  n m  k  m  n n k  m  k k   n  m   m    X k  k   n k m  n k    n  m   m    X k k   n k m  n k   Every tree with n vertices has n   edges Kraft inequal ity If the depths of the leaves of a binary tree are d    dn nX i di   and equality holds only if every in ternal node has sons Recurrences Master method T n  aT nb  fn a   b   If    such that fn  Onlogb a then T n  nlogb a If fn  nlogb a then T n  nlogb a log n If    such that fn  nlogb a and c   such that afnb  cfn for large n then T n  fn Substitution example Consider the following recurrence Ti  i  T i T   Note that Ti is always a power of two Let ti  log Ti Then we have ti  i  ti t   Let ui  ti i Dividing both sides of the previous equation by i we get ti i  i i  ti i  Substituting we nd ui     ui u   which is simply ui  i  So we nd that Ti has the closed form Ti  ii  Summing factors example Consider the following recurrence Ti  Tn  n T  n Rewrite so that all terms involving T are on the left side Ti  Tn  n Now expand the recurrence and choose a factor which makes the left side tele scope   T n T n   n   T n  T n   n     log n  T   T    log n  T     Summing the left side we get T n Sum ming the right side we get log nX i n i i Let c   and m  log n Then we have n mX i ci  n  cm   c     nc  clog n    nc  ck logc n    nk  n  n  n where k  log    Full history recur rences can often be changed to limited his tory ones example Consider the follow ing recurrence Ti    iX j Tj T   Note that Ti    iX j Tj  Subtracting we nd Ti  Ti    iX j Tj   iX j Tj  Ti And so Ti  Ti  i Generating functions  Multiply both sides of the equa tion by xi  Sum both sides over all i for which the equation is valid  Choose a generating function Gx Usually Gx  P i x i  Rewrite the equation in terms of the generating function Gx  Solve for Gx  The coecient of xi in Gx is gi Example gi  gi   g   Multiply and sum X i gix i  X i gix i  X i xi We choose Gx  P i x i Rewrite in terms of Gx Gx g x  Gx  X i xi Simplify Gx x  Gx    x Solve for Gx Gx  x  x x  Expand this using partial fractions Gx  x   x    x   x   X i ixi  X i xi  A  X i  i  xi So gi  i   Theoretical Computer Science Cheat Sheet Number Theory Graph Theory The Chinese remainder theorem There ex ists a number C such that C  r modm    C  rn modmn if mi and mj are relatively prime for i  j Eulers function x is the number of positive integers less than x relatively prime to x If Qn i p ei i is the prime fac torization of x then x  nY i peii pi   Eulers theorem If a and b are relatively prime then   a b mod b Fermats theorem   ap mod p The Euclidean algorithm if a  b are in tegers then gcda b  gcda mod b b If Qn i p ei i is the prime factorization of x then Sx  X djx d  nY i peii   pi    Perfect Numbers x is an even perfect num ber i x  n n and n is prime Wilsons theorem n is a prime i n    mod n Mobius inversion i     if i    if i is not squarefree r if i is the product of r distinct primes If Ga  X dja F d then F a  X dja dG a d   Prime numbers pn  n lnn n ln lnn  n n ln lnn lnn  O  n lnn  n  n lnn  n lnn  n lnn  O  n lnn   Denitions Loop An edge connecting a ver tex to itself Directed Each edge has a direction Simple Graph with no loops or multiedges Walk A sequence vev    e v  Trail A walk with distinct edges Path A trail with distinct vertices Connected A graph where there exists a path between any two vertices Component A maximal connected subgraph Tree A connected acyclic graph Free tree A tree with no root DAG Directed acyclic graph Eulerian Graph with a trail visiting each edge exactly once Hamiltonian Graph with a path visiting each vertex exactly once Cut A set of edges whose re moval increases the num ber of components Cutset A minimal cut Cut edge A size  cut kConnected A graph connected with the removal of any k   vertices kTough S  V S   we have k  cG S  jSj kRegular A graph where all vertices have degree k kFactor A kregular spanning subgraph Matching A set of edges no two of which are adjacent Clique A set of vertices all of which are adjacent Ind set A set of vertices none of which are adjacent Vertex cover A set of vertices which cover all edges Planar graph A graph which can be em beded in the plane Plane graph An embedding of a planar graphX vV degv  m If G is planar then nm  f   so f  n m  n  Any planar graph has a vertex with de gree   Notation EG Edge set V G Vertex set cG Number of components GS Induced subgraph degv Degree of v G Maximum degree G Minimum degree G Chromatic number EG Edge chromatic number Gc Complement graph Kn Complete graph Knn Complete bipartite graph rk  Ramsey number Geometry Projective coordinates triples x y z not all x y and z zero x y z  cx cy cz c   Cartesian Projective x y x y  y  mx b m b x  c  c Distance formula Lp and L metric p x  x  x  xjx  xjp  jx  xjpp lim p jx  xjp  jx  xjpp Area of triangle x y x y and x y   abs x  x y  yx  x y  y   Angle formed by three points  x y x y    cos   x y  x y   Line through two points x y and x y  x y  x y  x y     Area of circle volume of sphere A  r V  r  If I have seen farther than others it is because I have stood on the shoulders of giants  Issac Newton Theoretical Computer Science Cheat Sheet  Calculus Wallis identity                          Brounckers continued fraction expansion                 Gregrorys series                Newtons series                       Sharps series   p                       Eulers series                                                           Derivatives  dcu dx  c du dx  du v dx  du dx  dv dx  duv dx  u dv dx  v du dx  dun dx  nun du dx  duv dx  v  du dx   u dv dx  v  decu dx  cecu du dx  dcu dx  ln ccu du dx  dlnu dx   u du dx  dsinu dx  cosu du dx  dcos u dx   sinudu dx  dtanu dx  sec u du dx  dcotu dx  csc u du dx  dsec u dx  tanu sec u du dx  dcsc u dx   cotu csc udu dx  darcsinu dx  p  u du dx  darccos u dx  p  u du dx  darctanu dx    u du dx  darccot u dx    u du dx  darcsec u dx   u p  u du dx   darccsc u dx   u p  u du dx  dsinhu dx  coshu du dx  dcoshu dx  sinhu du dx  dtanhu dx  sech u du dx  dcothu dx   csch udu dx  dsech u dx   sech u tanhudu dx  dcsch u dx   csch u cothudu dx  darcsinhu dx  p   u du dx  darccosh u dx  p u   du dx   darctanhu dx    u du dx   darccoth u dx   u   du dx  darcsech u dx   u p  u du dx  darccsch u dx   jujp  u du dx  Integrals  Z cu dx  c Z u dx  Z u v dx  Z u dx Z v dx  Z xn dx   n  xn n    Z  x dx  lnx  Z ex dx  ex  Z dx   x  arctanx  Z u dv dx dx  uv  Z v du dx dx  Z sinx dx   cosx  Z cosx dx  sinx  Z tanx dx   ln j cosxj  Z cotx dx  ln j cosxj  Z sec x dx  ln j sec x tanxj  Z csc x dx  ln j cscx cotxj  Z arcsin xadx  arcsin x a  p a  x a   Partial Fractions Let N x and Dx be polynomial func tions of x We can break down N xDx using partial fraction expan sion First if the degree of N is greater than or equal to the degree of D divide N by D obtaining N x Dx  Qx  N x Dx where the degree of N  is less than that of D Second factor Dx Use the follow ing rules For a nonrepeated factor N x x aDx  A x a  N x Dx where A  N x Dx  xa  For a repeated factor N x x amDx  mX k Ak x amk N x Dx where Ak   k dk dxk  N x Dx  xa  The reasonable man adapts himself to the world! the unreasonable persists in trying to adapt the world to himself Therefore all progress depends on the unreasonable  George Bernard Shaw Theoretical Computer Science Cheat Sheet Calculus Cont  Z arccos xadx  arccos x a  p a  x a    Z arctan xadx  x arctan x a  a lna  x a    Z sinaxdx  a  ax sinax cosax  Z cosaxdx  aax sinax cosax  Z sec x dx  tanx   Z csc x dx   cotx  Z sinn x dx   sin n x cosx n  n  n Z sinn x dx  Z cosn x dx  cosn x sinx n  n  n Z cosn x dx  Z tann x dx  tann x n   Z tann x dx n    Z cotn x dx  cot n x n   Z cotn x dx n    Z secn x dx  tanx secn x n    n n  Z secn x dx n    Z cscn x dx  cot x csc n x n    n n  Z cscn x dx n    Z sinhx dx  coshx  Z coshx dx  sinhx   Z tanhx dx  ln j coshxj   Z cothx dx  ln j sinhxj  Z sech x dx  arctan sinhx  Z csch x dx  ln tanh x    Z sinh x dx   sinh x x  Z cosh x dx   sinh x   x  Z sech x dx  tanhx  Z arcsinh x a dx  x arcsinh x a  p x  a a    Z arctanh x a dx  x arctanh x a  a ln ja  xj  Z arccosh xadx    x arccosh x a  p x  a if arccosh xa   and a   x arccosh x a  p x  a if arccosh xa   and a     Z dxp a  x  ln  x p a  x  a     Z dx a  x  a arctan x a a    Z p a  x dx  x p a  x  a arcsin xa a    Z a  xdx  x a  x p a  x  a arcsin xa a    Z dxp a  x  arcsin x a a    Z dx a  x   a ln a xa x   Z dx a  x  x a p a  x  Z p a x dx  x p a x a ln xpa x  Z dxp x  a  ln xpx  a a    Z dx ax  bx   a ln  xa bx    Z x p a bxdx  bx aa bx b   Z p a bx x dx  p a bx a Z  x p a bx dx  Z xp a bx dx  p ln  p a bxpap a bx p a  a    Z p a  x x dx  p a  x  a ln a p a  x x   Z x p a  x dx   a  x  Z x p a  x dx  x  x  a p a  x  a arcsin xa a    Z dxp a  x    a ln a  p a  x x   Z x dxp a  x   p a  x  Z x dxp a  x   x  p a  x  a arcsin xa a    Z p a  x x dx  p a  x  a ln a p a  x x    Z p x  a x dx  p x  a  a arccos ajxj a     Z x p x a dx  x a  Z dx x p x  a  a ln  xa pa  x 
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved