SlideShare a Scribd company logo
2010 CS                                         	




                                                                          tniky1	




Copyright©	
  2010	
  tniky1	
  	
  All	
  rights	
  reserved.	
               Page	
  1
2010 CS                                                                   	


                                                       	

                              (                                )               	

                                                                                                	


                                                                                           	



                                                                                    	
  
                                                 	

                        	
     Copyright©	
  2010	
  tniky1	
  	
  All	
  rights	
  reserved.	
                                Page	
  2
2010 CS                                                                                     	


                                                           	

      •  5.1	
                                            	
                                                                      	
                         •                                                                                   	
      •  5.2	
                                                                	
  
                         •                                                                              	
      •  5.3	
                                                                       	
  
                         •                                                                                        	
  
      •  5.4	
                                                                                                           	
  
                         •                                                                       	
  




p87-­‐113	

         Copyright©	
  2010	
  tniky1	
  	
  All	
  rights	
  reserved.	
                                                       Page	
  3
2010 CS                                                                                       	


                                                                   	
                                                                                                                         (^^)	
  
   •                        	
  
              –                                                               	
                                               	

   •                        	
  
              –                                                         n             	
              –                                                                      1                      	
              –                                                                                                  ,	
                     	
              –                                                                                    	
              –                                                                                    	
              –                                                                                         (
                                                                                      )	
  
 p87	

         Copyright©	
  2010	
  tniky1	
  	
  All	
  rights	
  reserved.	
                                                           Page	
  4
2010 CS                                                                                                                                                                  	


                                                                                                                                                                        	
                                                                                                                              	
                                                                              	

                                                                                                                                                             	
                	
  1	
  	
  	
  	
  	
  	
  	
  	
  2	
  	
  	
  	
  	
  	
  	
  3	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  n	
                             	
  i	
  	
                                                                                                                                                                                                                                     best	

              HIRE-­‐ASSISTANT(n)	
                                                                                                                                                                                        	
              	
              1.                        best	
  ←	
  0 	
  =>                           0                                                                                                             	
              2.                        for	
  i	
  ←	
  1	
  to	
  n	
                                                                                                                                      	
  Ci	
            n	
  
              3.                         	
   do	
                  i                    	
              4.                        	
 	
 if	
                            i         best                                                                                                         	
      	
  Ch	
            m	
  
                                                                                                                                                                                                                                 (              )	
              5.                        	
 	
 	
 then	
  best	
  ←	
  i	
  	
  
              6.                         	
         	
        	
          	
   hire	
  candidate	
  i	
  

 p88	
                                                                                                                                                            O(nCi	
  +	
  mCh)	
  	
                                       m              	
         Copyright©	
  2010	
  tniky1	
  	
  All	
  rights	
  reserved.	
                                                                                                                                                                        Page	
  5
2010 CS                                                                              	


                                                                                                                  	

     •                                                                                           	
  


     •                                                                                                                 	

                                                                        2                               	
  
                                                                                          	
  
                                                                               1 n                             	
  



     •                                                                                           	
             	

               •                                                               n!
p88-­‐89	
                                                	
          Copyright©	
  2010	
  tniky1	
  	
  All	
  rights	
  reserved.	
                                             Page	
  6
2010 CS                                                                                    	


                                                                   	
                                          m(                      )

                                                                                                                                       	
   •                                                        	
  
              –                                                                                                                                     	
  
   •                                              (                     )     (                                 :                          	
  	
  	
  A:          )	
  
                                                                                                	
                                                                         	
                                                      	
                                               	


   •  (               )	
  
              –                                            Xi	
                                                       Xi	
  
                         •  A i                                                     	
               A               i	
                                    	
  
                         •  Xi I	
  {	
  i	
                                  }	
                    Xi I	
  {	
               i	
                                         }	
 p90	

         Copyright©	
  2010	
  tniky1	
  	
  All	
  rights	
  reserved.	
                                                                                          Page	
  7
2010 CS                                                                                               	


                                                                                                                                                                           	
   •                                                                                                                           	
  
                                                                                                                                               n/2
              –  (                         )                            	
                                                                       (1/2        n    )
                         •                        n                            	
                                                                                                                                                                      	
                         •                                                                                  1/2	
  
                         •                                                                  ?	
  
   •  E	
  [XA]	
  =	
  Pr{A}                                                                              	
  
              –                    A                           E                                                  XA	
                    Pr	
  
              –                   A                                                                                                       A
                                  	
  
              –                                                                     {i                                                }
                                                                               {i                                          }                            	


 p91	
                           E[Xi]	
  =	
  Pr{i                                       }	
  =	
  ½	
                                                            	

         Copyright©	
  2010	
  tniky1	
  	
  All	
  rights	
  reserved.	
                                                                                                       Page	
  8
both sides of the above equation to obtain
                        We wish to compute the expected number of heads, so we take the expectation of
2010 CS                                                          n
                                                       	
 to obtain
                        both sides of the above equation= E
                                                  E [X ]            X .                 i
                                            n                                   i=1
                        E [X ] = E
                                             i=1
                                                Xi     .The left side of the above equation is the expectation of the s      	
                                                        ables. By Lemma 5.1, we can easily compute the expectation
                             The left side of the above variables. is the expectation of the sum of nexpectation—it i
                                                        equation By equation (C.20)—linearity of random vari-
     •                       ables.	
  By Lemma 5.1, we can easily compute sum: it equals the each of the random
                                                        expectation of the the expectation of sum of the expectati
                             variables. By equation (C.20)—linearity of expectation—it is easy thecompute the
                                                        variables. Linearity of expectation makes to use of indicato
                                                                                           	
              –   Xi	
  =	
  expectation of the sum: it equals analytical of the expectations even whenrandom d
                              	
  {	
  i	
              }	
  
                                                        powerful the sum technique; it applies of the n there is
                             variables. Linearity of expectation makes the use ofcan easily compute the expected
              –  E[Xi]	
  =	
  Pr	
  {	
  i	
  
                                                        random variables. We now indicator random variables a
                                                }	
  =	
  ½	
  
                      powerful analytical technique; it applies even when there is dependence among the
                                                                      n
                                                                                           Xi(0	
  or	
  
                                                      E [X =	
  X compute i the expected number 1) heads:
              –       random variables. We now can] easily 	
  E 	
  
                                                                  =     X                                 of
                                                                                       1 n
                                                                                      i=1
                                                                                                            	
                                                 n                              n
                        E [X ] = E                    Xi                 =          E [X i ]
                                                i=1                            i=1 	
                                           n                                    n
          X                        =            E [X i ]                 =            1/2                       	
          (     )	
                                                            i=1
                                          i=1
                                                                          [                 ]	
  
                                           n                                         = n/2 .
                                                    =       1/2           	
  	
  2
                                                        i=1            Thus, compared to the method	
   used in equation (C.36), indic
                                                    = n/2 .            greatly simplify the	
  E[Y]	
                                                                          	
  	
  E[X+Y]	
  =	
  E[X]	
  + calculation. We shall use indicator rando
                                                                       out this book.
p91-­‐92	
                Thus, compared to the method used in equation (C.36), indicator random variables
         Copyright©	
  2010	
  tniky1	
  	
  All	
  simplify the calculation. We shall use indicator random variables through-
                          greatly rights	
  reserved.	
                                                                                Page	
  9	
                          out this book.
= 1 · (1/2) + 0 · (1/2)
2010 CS                                          = 1/2 .        	

           Thus the expected number of heads obtained by one flip of a fair
   E	
  [XA]	
  =	
  Pr{A}	
  	
  (                     )         	
           the following lemma shows, the expected value of an indicator
           associated with an event A is equal to the probability that A occur
   •                                                                          	
  
                    Lemma 5.1                   	
                              	
                    Given a sample space S and an event A in the sample space S,
                                                    	
                    Then E [X A ] = Pr { A}.
   •                                                           	
  
              –  Proof                                         	
  
                             By the definition of an indicator random variable from eq
   •                the	
definition of expected value, we have
                    E [X A ] = E [I { A}]              	

                             = 1 · Pr { A} + 0 · Pr { A}
                             = Pr { A} ,           	

 p91	
                    where A denotes S − A, the complement of A.
         Copyright©	
  2010	
  tniky1	
  	
  All	
  rights	
  reserved.	
            Page	
  10
n+1                                     n
                                                                                We wish to compute the expected number of heads, so we take the
2010 CS                                                                         both sides 	
 the above equation to obtain f (x) dx ≤
                                                                                           of        Approximation by integrals

                                                                                                      n
                                                                                                                                        m
                                                                                                                      When a summation can be expressed as n   k=m f (k), w
                                                                                                                                                                    k=m
                                                                                                                      increasing function, we can approximate it by integra
                                                                                E [X ] = E                  Xi        .
                                                                                                     i=1
                                                                                                           f (x) dx ≤
                                                                                                                          The≤integraldxappro
                                                                                                                          n
                                                                                                                           f	
                                                                                                                             (k)       f (x) .
                                                                                                                                               n                  n+1


                                                                                The left side of the above equationnumber. For of the sum of
                                                                                                                      is the expectation a lower b
                                                                                                                       m−1                   k=m                m

                                                                                ables. By Lemma 5.1, wejustification for this approximation is shown in F
                                                                                                                        The can easily compute the expectation of eac
      •                                        	
                                                                       represented as the n of expectation—it figure,
                                                                                variables. By equation (C.20)—linearity 1 the rectangles in theis easy  area of
                                                                                                                                                              	
                                                                                                                                                                                         n+1
                                                                                                                                                                                             dx
                                                                                                                        region under the curve. When fthe is a monotonically
                                                                                expectation of the sum: it equals the sum of≥                                                 (k) expectations o
                     –  Xi	
  =	
   	
  {            i	
                        variables.}	
  
                                                                                                                        use a similar method to provide the bounds
                                                                                                  Linearity of expectation makes the use of indicator ran
                                                                                                                           n+1
                                                                                                                                                                k
                                                                                                                                                     k=1 even when there is depend
                                                                                                                                                         n                     n      1       x
                     –  E[Xi]	
  =	
  Pr	
  {	
  i	
                            powerful analytical 	
  technique; it applies f (k) ≤
                                                                                          }	
  	
  =	
  	
  1	
  /	
  i             f (x) dx ≤                                    f (x) dx .
                                                                                random variables. We m                    now can easily compute= expected + 1)            the ln(n numbe
                                                                                                                                                                            m−1
                        	
  (i                                                         98
                                                                                                )	
  
                                                                                                                                                       k=m
                                                                                                                                                                  Xi(0	
  
                                                                                                             Chapter 5 Probabilistic Analysis and Randomized Algorithms or	
  1)
                                                           98             Chapter 5 Probabilistic Analysis approximationAlgorithmsgives a tight e
                                                                                       n         The integral and Randomized (A.12)
                                                                                                                1 n            	
 98                            Chapter 5 Probabilistic Analysis and Randomized Algorithms
                     –                                        E [X ] =	
  X	
  =	
  E [X ] = iE X (by For the upper bound,
                                                                            E                number. For equation (5.3))
                                                                                                           a lower bound, we obtain
                                                                                                                              n
                                                                                           X                                          i(5.5)
                                                                                               n             n+1            i=1
                                                                                                   i=1      n  1
                                                                                                               n                   dx
                                                              n                              E [X ] =
                                                                                                n      = E E [X i X≥ (by linearity of expectation)
                                                                                                                  ] i      (by equation (5.3))
                                                                                                           i=1 k                    x         n   n
                            E [X ] = E                              Xi          (by   equation (5.3)) i n
                                                                                             =            k=1i=1
                                                                                                         E [X ]
                                                                                                                           1
                                                                                                                              1                     dx
                                                                                                                                                   (5.5)
                                                            i=1                                     i=1 	
  [
                                                                                                       = n 1/i            equation 1)
                                                                                                                      ]	
             ≤
                                                                                                                    = (byln(n +(5.4)) .
                                                                                                       For the upper bound, we derive the inequality x
                                                                                                                              k 	
  
                                                       n                                           =       E [X ]   (by linearity of expectation)
                                                                                                                      i=1
                                                                                                                                i
                                                                                                                 = ln n + O(1) (by equation (A.7)) .                               (5.6)
                                                                                               n
      X                                     =                E [X i ]           (by linearity of expectation)       i=1k=2                      1
                                                                                             	
                                                                                             =             1/2
                                                                                                          Even though we interview n people, we only actually hire approximately ln n of
                                                                                                                     nn                       n	
      (      )	
                                                                                          them, on average. We summarize n result in the following lemma.
                                                                                                                    1          dx        this
 m                    	
                                                      i=1
                                                       n
                                                                                                    i=1 =
                                                                                                       Lemma 5.2
                                                                                                                   1/i ≤ 	
 (by equation[ln]	
                                                                                                                    k           x
                                                                                                                                         (5.4))
                                                                                                                                              1	
 	
           = ln n ,
                                            =                1/i                        = (5.4)) that candidates are presented in a
                                                                                                  .
                                                                                               Assuming
                                                                                                                k=2         1
                                                                                (by equation n/2 SSISTANT hasthetotal = ln nof,equationrandom order, algorithm HIRE-
                                                                                                               i=1
                                                                                               A = ln n + O(1) cost O(c ln n). (A.7)) .
                                                                                                              a       hiring (by
                                                                                method usedbound weyields 	
  theand approx
                                                                                                     which onlyofactuallycost boun
                                                                                                                                                   h
                                                      i=1
                                                    Thus, compared to thewe interviewthe people,our definition(C.36), indicator ra
                                                                                                        in equation the hiring hire
                                                                    Proof The bound follows immediately from
                                                               Even equation which yields n
                                                                     though
                                   = ln n + O(1) (by equation (A.7)) . (5.6).                                             (5.6)
p92-­‐93	
                                                     them,   thep324              	
  
                                                    greatly simplifyon average. We summarize this use indicator random va
                                                                            calculation. We shall result in the following lemma
                                                                               n
                                                     n this book. hiring actually ≤ ln + 1 .n 1
                                                                                    1
                            Even though we interviewoutpeople, we only cost of O(nc ).hirenapproximately ln n of
                                                                      The expected interview cost is a significant improvement over the worst-case
                                                                                                                                                                           Page	
  11	
                                                               result 5.2 k=1 k
           Copyright©	
  2010	
  tniky1	
  	
  All	
  rights	
  reserved.	
  
                                                                                                                                                           ≤ ln n + 1 .
                                                                                                                                  h
                            them, on average. We summarize thisLemmain the following lemma.
                                                                                                          Exercises
m             n+1              n          m−1     n
2010 CS                                                                               	
                                                                                           k=m
                                                                          f (x) dx ≤                 f (k) ≤                f (x) d
                                                                 The integral approximation (A.12) gives a
                                                                      m                k=m                            m−1
                                                                (
                                                              number. For a lower bound, we obtain                      )	
                                                                       The integral approximation (A.12) giv
                                                               n               n+1
    HIRE-­‐ASSISTANT(n)	
                                           1
                                                                    number. For a dxlower bound, we obtain
                                                                                                       	
          	
    1.           best	
  ←	
  0 	
  =>                            0     ≥           	
                                                              k=1
                                                                    kn 1     1       x dx
                                                                                    n+1
    2.           for	
  i	
  ←	
  1	
  to	
  n	
                                         	
  Ci	
          n	
  
    3.            	
   do	
                  i                     	
       ≥
                                                                        = ln(n + 1) . x
                                                                    k=1
                                                                        k         1
    4.           	
 	
 if	
                            i         best                  	
   	
  Ch	
     m	
  
    5.           	
 	
 	
 then	
  For←	
  i	
  	
   upper bound, + 1) .
                                                         best	
   the              = ln(n we derive the )	
                                                                                                         (
                                                                                                                 inequality
    6.            	
         	
        	
          	
   hire	
  candidate	
  i	
  
                                                           n                        n
                                                      1                         dx
                                                      For the upper bound, we derive the inequa
                                                              ≤
                                     O(nCi	
  +	
  mChk n 	
  O(mCh1 	
  	
  	
  	
  (Cn<<Ch
                                                      )	
  =              )	
   x i          )	
                                                k=2            1                         dx
             m(                             )                          ≤
                                                              = 	
  	
  ln n , 1 x
                                                      k=2
                                                               k
                                                                                                 (^^)	

                                               which yields=Ch ln n ,)	
  	
                                                                 O(	
  the bound
 p93	
                                                                  n
         Copyright©	
  2010	
  tniky1	
  	
  All	
  rights	
  reserved.	
  
                                                                              1
                                                                              which yields the bound                    Page	
  12
2010 CS                                                                        	


                                  	


                                                                                        	



                                                                                              	
  

                                                                                    (   )	




                                                                          	




     Copyright©	
  2010	
  tniky1	
  	
  All	
  rights	
  reserved.	
                                Page	
  13
2010 CS                                                                   	


                                  	

                                                                                              	
  
                                                                                         	




                                                                                    	




                                                                               	




     Copyright©	
  2010	
  tniky1	
  	
  All	
  rights	
  reserved.	
                                Page	
  14
2010 CS                                                                   	


                   	
 •  Hire-­‐Assistant                                             	
  




     Copyright©	
  2010	
  tniky1	
  	
  All	
  rights	
  reserved.	
          Page	
  15

More Related Content

Viewers also liked

デザインパターン(state,strategy,template)
デザインパターン(state,strategy,template)デザインパターン(state,strategy,template)
デザインパターン(state,strategy,template)
tniky1
 
動画像圧縮(コーデック)
動画像圧縮(コーデック)動画像圧縮(コーデック)
動画像圧縮(コーデック)
tniky1
 
アルゴリズムイントロダクション 14章
アルゴリズムイントロダクション 14章アルゴリズムイントロダクション 14章
アルゴリズムイントロダクション 14章
tniky1
 
アルゴリズムイントロダクション 8章
アルゴリズムイントロダクション 8章アルゴリズムイントロダクション 8章
アルゴリズムイントロダクション 8章
tniky1
 
Npc april fool2014
Npc april fool2014Npc april fool2014
Npc april fool2014
Ken Ogura
 
中の下のエンジニアを脱出するための仕事術
中の下のエンジニアを脱出するための仕事術中の下のエンジニアを脱出するための仕事術
中の下のエンジニアを脱出するための仕事術
Noriaki Kadota
 
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
Takahiro Inoue
 
Ctfのためのpython入門
Ctfのためのpython入門Ctfのためのpython入門
Ctfのためのpython入門
shiracamus
 
学生時代に知っておきたかったWeb技術の学び方の学び方 | リブセンス
学生時代に知っておきたかったWeb技術の学び方の学び方 | リブセンス学生時代に知っておきたかったWeb技術の学び方の学び方 | リブセンス
学生時代に知っておきたかったWeb技術の学び方の学び方 | リブセンス
Livesense Inc.
 

Viewers also liked (9)

デザインパターン(state,strategy,template)
デザインパターン(state,strategy,template)デザインパターン(state,strategy,template)
デザインパターン(state,strategy,template)
 
動画像圧縮(コーデック)
動画像圧縮(コーデック)動画像圧縮(コーデック)
動画像圧縮(コーデック)
 
アルゴリズムイントロダクション 14章
アルゴリズムイントロダクション 14章アルゴリズムイントロダクション 14章
アルゴリズムイントロダクション 14章
 
アルゴリズムイントロダクション 8章
アルゴリズムイントロダクション 8章アルゴリズムイントロダクション 8章
アルゴリズムイントロダクション 8章
 
Npc april fool2014
Npc april fool2014Npc april fool2014
Npc april fool2014
 
中の下のエンジニアを脱出するための仕事術
中の下のエンジニアを脱出するための仕事術中の下のエンジニアを脱出するための仕事術
中の下のエンジニアを脱出するための仕事術
 
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
 
Ctfのためのpython入門
Ctfのためのpython入門Ctfのためのpython入門
Ctfのためのpython入門
 
学生時代に知っておきたかったWeb技術の学び方の学び方 | リブセンス
学生時代に知っておきたかったWeb技術の学び方の学び方 | リブセンス学生時代に知っておきたかったWeb技術の学び方の学び方 | リブセンス
学生時代に知っておきたかったWeb技術の学び方の学び方 | リブセンス
 

Similar to アルゴリズムイントロダクション 5.1-5.2章

Wwf file8 6-
Wwf file8 6-Wwf file8 6-
Wwf file8 6-
y246ra
 
Silent vlfree
Silent vlfreeSilent vlfree
Adagio in G Minor for Piano and Violin Duet
Adagio in G Minor for Piano and Violin DuetAdagio in G Minor for Piano and Violin Duet
Adagio in G Minor for Piano and Violin Duet
sayakahime
 
【企画書】地球横断
【企画書】地球横断【企画書】地球横断
【企画書】地球横断
Shunsuke Yagi
 
【企画書】地球横断
【企画書】地球横断【企画書】地球横断
【企画書】地球横断
Shunsuke Yagi
 
Facebook Page Communications for Business
Facebook Page Communications for BusinessFacebook Page Communications for Business
Facebook Page Communications for Business
Social-Link
 
비즈니스를 위한 페이스북_페이지_커뮤니케이션_20110210_final
비즈니스를 위한 페이스북_페이지_커뮤니케이션_20110210_final비즈니스를 위한 페이스북_페이지_커뮤니케이션_20110210_final
비즈니스를 위한 페이스북_페이지_커뮤니케이션_20110210_final
Juny Lee
 
Cv S.Uiterwijk
Cv S.UiterwijkCv S.Uiterwijk
Cv S.Uiterwijk
Suiterwijk
 
6o kefalaio
6o kefalaio6o kefalaio
6o kefalaio
stereotypicalgamer
 
Sheet11- Appendix
Sheet11- AppendixSheet11- Appendix
Sanitary Ware Catalog
Sanitary Ware CatalogSanitary Ware Catalog
Sanitary Ware Catalog
jburtka
 
Sterling's Mane News August 2010
Sterling's Mane News August 2010Sterling's Mane News August 2010
Sterling's Mane News August 2010
Craig Freeman
 
If You Be My Baby
If You Be My BabyIf You Be My Baby
If You Be My Baby
mabbagliati
 
Pole Trailer Extension
Pole Trailer ExtensionPole Trailer Extension
Pole Trailer Extension
DraftingResource
 
CAR Email 6.4.02 (s)
CAR Email 6.4.02 (s)CAR Email 6.4.02 (s)
CAR Email 6.4.02 (s)
Obama White House
 
Illinois Launch Presentation
Illinois Launch PresentationIllinois Launch Presentation
Illinois Launch Presentation
EDeLaPaz_PDA
 
Hardware acceleration of TEA and XTEA algorithms on FPGA, GPU and multi-core ...
Hardware acceleration of TEA and XTEA algorithms on FPGA, GPU and multi-core ...Hardware acceleration of TEA and XTEA algorithms on FPGA, GPU and multi-core ...
Hardware acceleration of TEA and XTEA algorithms on FPGA, GPU and multi-core ...
Vivek Venugopalan
 
유저스토리랩 회사소개서
유저스토리랩 회사소개서유저스토리랩 회사소개서
유저스토리랩 회사소개서
userstorylab
 
Fall Semester Calendar Counselor Ed Department
Fall Semester Calendar Counselor Ed  DepartmentFall Semester Calendar Counselor Ed  Department
Fall Semester Calendar Counselor Ed Department
wcucounselored
 
Tab3
Tab3Tab3
Tab3
jman148
 

Similar to アルゴリズムイントロダクション 5.1-5.2章 (20)

Wwf file8 6-
Wwf file8 6-Wwf file8 6-
Wwf file8 6-
 
Silent vlfree
Silent vlfreeSilent vlfree
Silent vlfree
 
Adagio in G Minor for Piano and Violin Duet
Adagio in G Minor for Piano and Violin DuetAdagio in G Minor for Piano and Violin Duet
Adagio in G Minor for Piano and Violin Duet
 
【企画書】地球横断
【企画書】地球横断【企画書】地球横断
【企画書】地球横断
 
【企画書】地球横断
【企画書】地球横断【企画書】地球横断
【企画書】地球横断
 
Facebook Page Communications for Business
Facebook Page Communications for BusinessFacebook Page Communications for Business
Facebook Page Communications for Business
 
비즈니스를 위한 페이스북_페이지_커뮤니케이션_20110210_final
비즈니스를 위한 페이스북_페이지_커뮤니케이션_20110210_final비즈니스를 위한 페이스북_페이지_커뮤니케이션_20110210_final
비즈니스를 위한 페이스북_페이지_커뮤니케이션_20110210_final
 
Cv S.Uiterwijk
Cv S.UiterwijkCv S.Uiterwijk
Cv S.Uiterwijk
 
6o kefalaio
6o kefalaio6o kefalaio
6o kefalaio
 
Sheet11- Appendix
Sheet11- AppendixSheet11- Appendix
Sheet11- Appendix
 
Sanitary Ware Catalog
Sanitary Ware CatalogSanitary Ware Catalog
Sanitary Ware Catalog
 
Sterling's Mane News August 2010
Sterling's Mane News August 2010Sterling's Mane News August 2010
Sterling's Mane News August 2010
 
If You Be My Baby
If You Be My BabyIf You Be My Baby
If You Be My Baby
 
Pole Trailer Extension
Pole Trailer ExtensionPole Trailer Extension
Pole Trailer Extension
 
CAR Email 6.4.02 (s)
CAR Email 6.4.02 (s)CAR Email 6.4.02 (s)
CAR Email 6.4.02 (s)
 
Illinois Launch Presentation
Illinois Launch PresentationIllinois Launch Presentation
Illinois Launch Presentation
 
Hardware acceleration of TEA and XTEA algorithms on FPGA, GPU and multi-core ...
Hardware acceleration of TEA and XTEA algorithms on FPGA, GPU and multi-core ...Hardware acceleration of TEA and XTEA algorithms on FPGA, GPU and multi-core ...
Hardware acceleration of TEA and XTEA algorithms on FPGA, GPU and multi-core ...
 
유저스토리랩 회사소개서
유저스토리랩 회사소개서유저스토리랩 회사소개서
유저스토리랩 회사소개서
 
Fall Semester Calendar Counselor Ed Department
Fall Semester Calendar Counselor Ed  DepartmentFall Semester Calendar Counselor Ed  Department
Fall Semester Calendar Counselor Ed Department
 
Tab3
Tab3Tab3
Tab3
 

Recently uploaded

June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
Dinusha Kumarasiri
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
AWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptxAWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptx
HarisZaheer8
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
alexjohnson7307
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
Data Hops
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 

Recently uploaded (20)

June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
AWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptxAWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptx
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 

アルゴリズムイントロダクション 5.1-5.2章

  • 1. 2010 CS tniky1 Copyright©  2010  tniky1    All  rights  reserved.   Page  1
  • 2. 2010 CS ( )   Copyright©  2010  tniky1    All  rights  reserved.   Page  2
  • 3. 2010 CS •  5.1     •  •  5.2     •  •  5.3     •    •  5.4     •    p87-­‐113 Copyright©  2010  tniky1    All  rights  reserved.   Page  3
  • 4. 2010 CS (^^)   •    –    •    –  n –  1 –  ,   –  –  –  ( )   p87 Copyright©  2010  tniky1    All  rights  reserved.   Page  4
  • 5. 2010 CS  1                2              3                                  n  i   best HIRE-­‐ASSISTANT(n) 1.  best  ←  0  => 0 2.  for  i  ←  1  to  n      Ci     n   3.    do   i 4.  if   i best    Ch     m   ( ) 5.  then  best  ←  i     6.          hire  candidate  i   p88 O(nCi  +  mCh)   m Copyright©  2010  tniky1    All  rights  reserved.   Page  5
  • 6. 2010 CS •    •  2     1 n   •    •  n! p88-­‐89 Copyright©  2010  tniky1    All  rights  reserved.   Page  6
  • 7. 2010 CS m( ) •    –    •  ( ) ( :      A: )   •  ( )   –  Xi   Xi   •  A i   A i     •  Xi I  {  i   } Xi I  {   i   } p90 Copyright©  2010  tniky1    All  rights  reserved.   Page  7
  • 8. 2010 CS •    n/2 –  ( )   (1/2 n ) •  n •  1/2   •  ?   •  E  [XA]  =  Pr{A}   –  A E XA   Pr   –  A A   –  {i } {i } p91 E[Xi]  =  Pr{i }  =  ½   Copyright©  2010  tniky1    All  rights  reserved.   Page  8
  • 9. both sides of the above equation to obtain We wish to compute the expected number of heads, so we take the expectation of 2010 CS n to obtain both sides of the above equation= E E [X ] X . i n i=1 E [X ] = E i=1 Xi .The left side of the above equation is the expectation of the s ables. By Lemma 5.1, we can easily compute the expectation The left side of the above variables. is the expectation of the sum of nexpectation—it i equation By equation (C.20)—linearity of random vari- •  ables.  By Lemma 5.1, we can easily compute sum: it equals the each of the random expectation of the the expectation of sum of the expectati variables. By equation (C.20)—linearity of expectation—it is easy thecompute the variables. Linearity of expectation makes to use of indicato –  Xi  =  expectation of the sum: it equals analytical of the expectations even whenrandom d  {  i   }   powerful the sum technique; it applies of the n there is variables. Linearity of expectation makes the use ofcan easily compute the expected –  E[Xi]  =  Pr  {  i   random variables. We now indicator random variables a }  =  ½   powerful analytical technique; it applies even when there is dependence among the n Xi(0  or   E [X =  X compute i the expected number 1) heads: –  random variables. We now can] easily  E   = X of 1 n i=1 n n E [X ] = E Xi = E [X i ] i=1 i=1 n n X = E [X i ] = 1/2 ( ) i=1 i=1 [ ]   n = n/2 . = 1/2    2 i=1 Thus, compared to the method   used in equation (C.36), indic = n/2 . greatly simplify the  E[Y]    E[X+Y]  =  E[X]  + calculation. We shall use indicator rando out this book. p91-­‐92 Thus, compared to the method used in equation (C.36), indicator random variables Copyright©  2010  tniky1    All  simplify the calculation. We shall use indicator random variables through- greatly rights  reserved.   Page  9 out this book.
  • 10. = 1 · (1/2) + 0 · (1/2) 2010 CS = 1/2 . Thus the expected number of heads obtained by one flip of a fair E  [XA]  =  Pr{A}    ( ) the following lemma shows, the expected value of an indicator associated with an event A is equal to the probability that A occur •    Lemma 5.1 Given a sample space S and an event A in the sample space S, Then E [X A ] = Pr { A}. •    –  Proof   By the definition of an indicator random variable from eq •  the definition of expected value, we have E [X A ] = E [I { A}] = 1 · Pr { A} + 0 · Pr { A} = Pr { A} , p91 where A denotes S − A, the complement of A. Copyright©  2010  tniky1    All  rights  reserved.   Page  10
  • 11. n+1 n We wish to compute the expected number of heads, so we take the 2010 CS both sides the above equation to obtain f (x) dx ≤ of Approximation by integrals n m When a summation can be expressed as n k=m f (k), w k=m increasing function, we can approximate it by integra E [X ] = E Xi . i=1 f (x) dx ≤ The≤integraldxappro n f (k) f (x) . n n+1 The left side of the above equationnumber. For of the sum of is the expectation a lower b m−1 k=m m ables. By Lemma 5.1, wejustification for this approximation is shown in F The can easily compute the expectation of eac •    represented as the n of expectation—it figure, variables. By equation (C.20)—linearity 1 the rectangles in theis easy area of n+1 dx region under the curve. When fthe is a monotonically expectation of the sum: it equals the sum of≥ (k) expectations o –  Xi  =    { i   variables.}   use a similar method to provide the bounds Linearity of expectation makes the use of indicator ran n+1 k k=1 even when there is depend n n 1 x –  E[Xi]  =  Pr  {  i   powerful analytical  technique; it applies f (k) ≤ }    =    1  /  i f (x) dx ≤ f (x) dx . random variables. We m now can easily compute= expected + 1) the ln(n numbe m−1  (i 98 )   k=m Xi(0   Chapter 5 Probabilistic Analysis and Randomized Algorithms or  1) 98 Chapter 5 Probabilistic Analysis approximationAlgorithmsgives a tight e n The integral and Randomized (A.12) 1 n 98 Chapter 5 Probabilistic Analysis and Randomized Algorithms –  E [X ] =  X  =  E [X ] = iE X (by For the upper bound, E number. For equation (5.3)) a lower bound, we obtain n X i(5.5) n n+1 i=1 i=1 n 1 n dx n E [X ] = n = E E [X i X≥ (by linearity of expectation) ] i (by equation (5.3)) i=1 k x n n E [X ] = E Xi (by equation (5.3)) i n = k=1i=1 E [X ] 1 1 dx (5.5) i=1 i=1 [ = n 1/i equation 1) ]   ≤ = (byln(n +(5.4)) . For the upper bound, we derive the inequality x k   n = E [X ] (by linearity of expectation) i=1 i = ln n + O(1) (by equation (A.7)) . (5.6) n X = E [X i ] (by linearity of expectation) i=1k=2 1 = 1/2 Even though we interview n people, we only actually hire approximately ln n of nn n ( )   them, on average. We summarize n result in the following lemma. 1 dx this m i=1 n i=1 = Lemma 5.2 1/i ≤ (by equation[ln] k x (5.4)) 1 = ln n , = 1/i = (5.4)) that candidates are presented in a . Assuming k=2 1 (by equation n/2 SSISTANT hasthetotal = ln nof,equationrandom order, algorithm HIRE- i=1 A = ln n + O(1) cost O(c ln n). (A.7)) . a hiring (by method usedbound weyields  theand approx which onlyofactuallycost boun h i=1 Thus, compared to thewe interviewthe people,our definition(C.36), indicator ra in equation the hiring hire Proof The bound follows immediately from Even equation which yields n though = ln n + O(1) (by equation (A.7)) . (5.6). (5.6) p92-­‐93 them, thep324   greatly simplifyon average. We summarize this use indicator random va calculation. We shall result in the following lemma n n this book. hiring actually ≤ ln + 1 .n 1 1 Even though we interviewoutpeople, we only cost of O(nc ).hirenapproximately ln n of The expected interview cost is a significant improvement over the worst-case Page  11 result 5.2 k=1 k Copyright©  2010  tniky1    All  rights  reserved.   ≤ ln n + 1 . h them, on average. We summarize thisLemmain the following lemma. Exercises
  • 12. m n+1 n m−1 n 2010 CS k=m f (x) dx ≤ f (k) ≤ f (x) d The integral approximation (A.12) gives a m k=m m−1 ( number. For a lower bound, we obtain ) The integral approximation (A.12) giv n n+1 HIRE-­‐ASSISTANT(n) 1 number. For a dxlower bound, we obtain 1.  best  ←  0  => 0 ≥ k=1 kn 1 1 x dx n+1 2.  for  i  ←  1  to  n      Ci     n   3.    do   i ≥ = ln(n + 1) . x k=1 k 1 4.  if   i best    Ch     m   5.  then  For←  i     upper bound, + 1) . best   the = ln(n we derive the ) ( inequality 6.          hire  candidate  i   n n 1 dx For the upper bound, we derive the inequa ≤ O(nCi  +  mChk n  O(mCh1        (Cn<<Ch )  = )   x i ) k=2 1 dx m( ) ≤ =    ln n , 1 x k=2 k (^^) which yields=Ch ln n ,)   O(  the bound p93 n Copyright©  2010  tniky1    All  rights  reserved.   1 which yields the bound Page  12
  • 13. 2010 CS   ( ) Copyright©  2010  tniky1    All  rights  reserved.   Page  13
  • 14. 2010 CS   Copyright©  2010  tniky1    All  rights  reserved.   Page  14
  • 15. 2010 CS •  Hire-­‐Assistant   Copyright©  2010  tniky1    All  rights  reserved.   Page  15