Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Successfully reported this slideshow.

Like this presentation? Why not share!

2,195 views

Published on

アルゴリズムイントロダクション 第5.4章 勉強会資料

下記でPPT版，KEY版も配布してます．

http://tniky1.com/study/

Published in:
Technology

No Downloads

Total views

2,195

On SlideShare

0

From Embeds

0

Number of Embeds

1,288

Shares

0

Downloads

9

Comments

0

Likes

3

No embeds

No notes for slide

- 1. 2010 CS 3 2010/06/12 niky1 h:p://www.tniky1.com/ Copyright© 2010 tniky1 All rights reserved. Page 1
- 2. 2010 CS 1 2 3 n i best Copyright© 2010 tniky1 All rights reserved. Page 2
- 3. 2010 CS 5.4.4 (^^;) Copyright© 2010 tniky1 All rights reserved. Page 3
- 4. 2010 CS • – – ( ) – • – k ( ) – k+1 p109 Copyright© 2010 tniky1 All rights reserved. Page 4
- 5. 2010 CS 5.4 Probabilistic analysis and further uses of indicator r the ﬁrst k applicants, and hiring th then rejecting a higher score than all preceding applicants. If applicant was among the ﬁrst k interviewed, th This strategy is formalized in the procedure O appears below. Procedure O N -L INE -M AXIMUM 1 2 k k+1 k+2 n we wish to hire. O N -L INE -M AXIMUM (k, n) 1 bestscore ← −∞ 2 for i ← 1 to k 3 do if score(i) > bestscore 4 then bestscore ← score(i) 5 for i ← k + 1 to n I I bestscore 6 do if score(i) > bestscore (i≤k) bestscore (i>k) 7 then return i 8 return n We wish to determine, for each possible va 1 k hire the most qualiﬁed applicant. We will the n k implement the strategy with that value. For th Copyright© 2010 tniky1 All rights reserved. Let M( j ) = max1≤i≤ j {score(i)} denote the m Page 5 through j . Let S be the event that we succe
- 6. 7 then return i n8 i return n 2010 CS We wish to determine, for each possible value Chapter 5 Probabilistic Analysis and Randomized Algorithms of k, the probability that Chapter Probabilistic Analysis e, hire the most qualiﬁed applicant. We will thenthat we the best possible k, a for each5 possible value of k, and Randomized Algorithms the probability choose applicant.• We will 5 Probabilisticthe bestand Randomized Algorithms implementChapter then positions Analysis possiblewhereas Biassume that k on ﬁxe 116 thevalues in choose 1value. For the moment, depends only is strategy with that through i S 1, k, and ordering of the −with that value.max1≤i≤ j moment, assume that maximum score among applicants Let M( the = For the {score(i)} ) k denote the k is ﬁxed. whether • ) Svalue in position i is greater than the values in all other positions. The j (k ( ordering of. of values inthe event 1 throughsucceed − not affect whether thescore(i)} denotetheSvalues in positionswe through iin choosing the Bi depends ordering k) through j the Let be positions that 1 i − 1 does 1, the maximum score among applicants 1 whereas best-qualiﬁ event positionletis in position is greater than value in − in all does positi evalue in thatand valueiof the valuesi in positions 1 through ithe 1, whereas not app applicant, iorderingSgreater than all of them, best-qualiﬁed position i other Bi dep whether the isucceed the choosing the and the the values best-qualiﬁed we be in event that we succeed when event • thatith theofthe value in the best-qualiﬁed ithanare does not we other p the ordering whether values when position 1 1throughappli- 1Thus we can all have th cant the orderingsucceed in positions i is greater Si the values in apply we various − affect is the of one Sinterviewed. positionsthethrough i − 1. disjoint, affect wh the values in Since i viewed. =(C.15) theobtain the Si are disjoint, wesucceed when− 1 best-qualiﬁed a Pr {S} Since to {Si }. Noting that we k of them, and the valuedoes not affec ordering of n Pr various values in positions have that i the in position i equation in position i is greater than all never 1 through value value in,2,•••,k i is greater than all of them, and the value in posit i=1 = 1 – never position when the best-qualiﬁed ap-Noting that one of the succeedwe have that Pr {S } = 0 for i = 1, 2, . . . , k. Thus, plicant is we ﬁrst the values in positions 1 through i − 1. Thus we c k, affect the{B ∩ Oi } = Pr {Bi i {Oi } 2, . . . k. Thus, we } = Praffect {S of 0 for Pr the . ordering = Pr {Sihave thati Pr thei }ordering} of= 1,values,ini positions 1 through i − 1. Thus k, we obtain equation equationto obtain obtain (C.15)+1,•••,n to The probability Prk i(C.15) – = {B } is clearly 1/n, since the maximum is equally likely to be n inPr {Sone ofPr {B{Si } O{B= Pr {Bi } PrOi to}Pr ){O i: the maximum value in po- (5.1 Pr any i= = thei }ni= Pr. i ii: ∩For }event i {Bi } occur,i }k+1 i-‐1 {S} } Pr {S positions. Oi = Pr {Oi . (O . Pr ∩ }(B ) sitions 1 through i − 1 must be in one of the ﬁrst k (5.13) i=k+1 positions, and it is equally n likely to be The probability− 1 clearly Consequently, Pr {Oi } maximum isand lik The probability Pr {Bii} is {Bi } is clearly 1/n, the maximum is − 1) equall in any of these Pr positions. 1/n, since since the = k/(i equally compute Pr {Si }. n order to succeed Pr {Sany k/(n(i − onenUsing equation (5.13),For Oi when ithe best-qualiﬁed applica We nowin any 1)). of the In positions. we event O to occur, the maximum i } = one of the positions. For event haveSi }.in p109-‐110 to succeed when the best-qualiﬁedthe to occur, the maximum valu is the ith one, two1things must− 1 mustFirst, applicant ﬁrst k positions, and In order i happen. be of must the best-qualiﬁed applicant must sitions the best-qualiﬁedin one in one ofbe k positions, and it i n First, throughmust be applicant the ﬁrsts must happen. an eventll − 1eserved. we denote by B . Second, the algorithm must n in {S} =1likely010 tniky1 i A in any of these i − 1 positions. Consequently, Pr {O } = sitions Copyright© 2 position throughbe} rights r Pr we denote by {Si . which the algorithm imust notwhich i, Pr to B Second, Page 6 likely to be in any iof these i − 1 positions. Consequently, Pr {O } = k/(i i
- 7. 7 then returnPr {Si } = Pr {Bi }∩ Oi } {BiPr {Bii{Si } {O{Bi.{Bi ∩ O}} .= Pr {Bi } Pr { i {S = Pr = ∩ Pr } Pr Pr iPr } Pr {Oi i O = = }8 return n 2010 CS The probability Pr {Bi } is Pr The} probability1/n, maximummaxim The probability clearly 1/n, since Pr {Bi } is clearly equ {Bi is clearly the since the is 1/ 116 any one of theonepositions. positions. ofOthe noccur,i the occur, e in inChapter 5 the n For event For to and Randomize any n of Probabilistic Analysis positions.maxim in any one i event O to ForChapter 5 Probabilistic Analysissitions each possible value ofmust the in one of mustﬁrst in p We wish to determine, and Randomized Algorithms isitions k,through i ﬁrst1k the that for 1 through 1i through − 1in 1 be the − positions, sitions − 1 must be one of probability be k be We to be in any − 1 positions. Consequently,− 1{Oi a likely will then of these ibe 1 any of possible k, } likely toandin any of these Algorithms − in positions. Consequentlhire the most qualiﬁed applicant. Randomized i likely to the best these i Pr posi Chapter 5 Probabilistic Analysis chooseimplementChapter 5 Probabilistic= k/(n(i} andi RandomizediUsing(5.13),− 1)).only wethro116ordering of the strategy with that1value. = 1)). of the {S } = Biassume (5.13), on ﬁxe Pr {Si } Pr {Si thevalues in positions Analysis −For 1,−Prequationk/(n(ipositionsk1ishave k/(n(i 1)). Using moment, equation that equati ordering−the whereas in through values depends Algorithms we have Using n n nwhether the = max1≤i≤ j {score(i)} Prwhether ithe value all=position {Sis applicantsLet M( j ) value in position i {S}greater than the }maximum score among} greater th denote= {S Pr is = {S} Prthe values{Si } in other positions. The Pr in Pr {S} Pr i i ordering Let be positions that 1 i i=k+1 the − not whereas best-qualiﬁordering of. of theSvalues in positionswe throughdoes choosing positions the throthrough j the values inthe event 1 throughsucceed iinvalues i=k+1 the Bi depends ordering − 1 i=k+1 of 1, affect whether 1 in −applicant, orderingSgreater values i ofk+1 weink position i values n best-qualiﬁedi app whether the valueiof the than all invalue+2 succeed when i the 1,n whereas not dep and letis in position k is positions n1 through greater k allBof th 1 the event that k and the the is in all other positi be 2 greater than value in position than nvalue in position i them, k i doescant the ordering values in in position 1 1through thanofThus we can1) positio ordering whether the value positions in(i − 1) n(i Si1) = does n(i inaffect whp ith one the values in =Since =the ordering 1.1 i=k+1 not all other is greater various − thedisjoint,− inaffect is the of theof interviewed. positionsthethrough ii−−arethe valueswe have th affect i=k+1 through i − 1 does not affec values apply {S} =(C.15) to obtain the values inwe nnever(C.15) 1 whenvalue in1position ia ordering of Noting that positionssucceed 1 n i=k+1equation in position ii }. greater than all of them, and obtain n best-qualiﬁedPrvalue i=1 Pr {S is equation1 n k k to the ktheplicant is one of in i-‐1ﬁrst thei values n positions 10throughn1, 2, 1. −,1k.in posit value theposition we have thatthan all = them,i and the . . k, is greater Pri {Si1 of i − 1 = i − value Thus, c affect the{Bi ∩ the} ordering} of = i }in = in i=k+1 for 1 = i=k+1.ii − 1. Thus ordering= Pr {Bi Pr {O values − }Pr {Si } = Praffect Oi of thePri=k+1} = Pr {Bi ∩ Oi } = Pr {BiThus we . .{S n positions through } Pr {Oi }obtain equation equationto obtain obtain k n−1 1 k n−1 1 (C.15) (C.15) to i 1 2 k The probability Prk+1,•••,n k n−1 likely to be – = {Bi } is clearly 1/n, since= . maximum is equally . the 1 n = The probability Pr {B } is clearly 1/n, sin . = any i } = the } i= Pr. i }(Bi: ∩For }event O } occur,i }k+1 i-‐1 i n i=k iinPr {Sone ofPr {B{Si } O{B= Pr {Bi }n ii=ki ito}Pr )i=k(Oi: the maximum value in po- (5.1 Pr {B n. of .Pr {S} = Pr {Si n positions. Oi =in anyi ione{Oi the n positions. For event Pr ∩ i Pr {O ) sitions 1 through i − 1 must be in one of the ﬁrst k positions, and it is equally i=k+1 n sitions since since −i 1 summation from lik The probability Pr {Bii}We clearly approximate bytheapproximate k/(i besummationo in any of these is {Bi }We clearly 1/n,We Pr {Oto maximum in equall is 1/n, 1 through i the} = by this is one must equally likely to be The probability− 1approximate Consequently,bound thisboundis − 1) and abov Pr positions. by integrals to maximum integrals to boun integrals compute Pr {Sithe In positions. For event O of best-qualiﬁed applica }. n order(5.13), we have we to occur, the maximum We nowin any 1)). of the inequalities (A.12), we in any thethese i − positions to succeed when havePr {Sany k/(n(i − onenUsing equationlikely to be(A.12),inequalities (A.12),1we have valu in i } = one of the the inequalities have the positions. For event Oi to occur, the maximum iis the p110 one, two1things must− 1 mustFirst,n−111 best-qualiﬁed1k positions, and ith sitions throughn i1 happen. 1 ibe= k/(n(i 1− 1)).n−1 applicant must n−1 n inthe ﬁrst k positions, and it(5 Pr1{S } n−1 one nofn−1 1 ﬁrst the Using equation i n−1 sitions 1 through i All − 1eserved. we ≤ indx≤ of .the . dx ≤dx . algorithm 1must nin {S} = Copyright© 2010 tniky1 }in any x dx be x − 1 positions.x Consequently, Pr {Odx . positionlikely Pr {S rights r must denote by Bi i x≤n i, an to be whichof these i i one n event ≤ Second, the i ≤ dx x }= Page 7 Pr x k positions. Consequently, Pr {O } = k/(i likely to be in any iof these i − 1k i=k k−1 i=k k k−1 i=k k−1 i
- 8. nLet Pr {S}j )== max{Si } {Bji }{score(i)} denotePr {Smaximum score among appli M( probability1≤i≤ is clearly 1/n, since thethe } =isPr {B likely to be Pr {B } The Pr Pr maximum equally 2010 CS any one of the n positions. For event Oi to occur,i the maximumi value in}po- in ∩ Oi = ithrough j . 1Let i=k+1 S be the event that we succeed in choosing the best-q sitions through i − 1 must be in one of the ﬁrst k positions, and it is equally napplicant,=and let k iofbe the−event thatConsequently, Pr {Oi } = k/(i − 1) iandis clearly likely to be in any 1) these i 1 positions. we succeed when Pr {B } S The probability the best-qualiﬁedcant is the n(i − = k/(n(i interviewed. Since in any i=k+1 Pr {Si } ith one− 1)). Using equation (5.13), thehave one of the n positions. ha we various Si are disjoint, we F k n n 1 nPr {S} = = i=1 Pri {S1 }. Noting i sitions 1 through − best-qualiﬁ that we never succeed wheni the 1 must be Pr {S} n i=k+1 −Pr {Si } =plicant is one n−1i=k+1 ﬁrst k, we have that likely}to be forany of these. i, − 1 of the = 1,2,•••,k Pr {Si = 0 in i = 1, 2, . . k. Th k 1obtain = n i=k i n. k = k+1,•••,n Pr {Si } = k/(n(i − 1)). Using eq = n n(i − 1) i=k+1 nPr {S} approximatePr {Si } .1to bound this summation from{S} and below. By Pr {S } We = by integrals k n Pr above = = the inequalities (A.12), we have i i=k+1 n i=k+1 i − 1 n n−1 i=k+1 1/k + 1/(k+1) + 1/(k+2) + ••• + 1/(n-‐1) 1 1 n−1 n−1 1 We now≤compute 1 .x{Si .}. In order to succeed when the best-qualiﬁed k x dx = i=k i k≤ Pr dx k−1 n k apis the ith one, two things mustus the bounds First, the= n i=k i Evaluating these deﬁnite integrals gives happen. best-qualiﬁed applicant m n(i − 1) i=k+1the algorithm min position i, an event which bounddenote by BfromSecond, below. By k We approximate by integrals to we this summation i . above and k (ln n − ln k) ≤ Pr {S} ≤ (ln(n − 1) − ln(k − 1)) , nselect anyinequalities (A.12), we have positions k + 1 through ik− 1, which happens n the of the applicants in n 1 which provide a that k + 1 ≤ j ≤ i Because we wish to =for each nj1such rather1tight bound1 for Pr {S}.− 1, we ﬁnd that score( j ) < bestscore in maximize our probability of success, let us focus on choosing the value of k that maximizesi=k+1 i − 1n the n−1 n−1 dx ≤ are unique, we. can ignore the possibility of score( j ) = bes ≤ dx (Because scores {S}.i (Besides, the lower-bound expression is easier to maximize lowerkbound on Pr k Pr{S} x k−1 x than the upper-bound must be the case that all of the n k n−1 1 i=kIn other words, it expression.) Differentiating the expression (k/n)(ln values score(k + 1) t −ln k)score(i − 1) are less than M(k); if any are greater = n p110-‐111 Evaluatingk, we obtain with respect to these deﬁnite integrals gives us the bounds . than M(k) we will instead i k k 1 Copyright© 2010 tniky1 All rights reserved. i=k Page 8 the index of−the .ﬁrst one (ln(n 1) − ln(k We use Oi to denote the event th (ln n(ln ln k − 1) ≤ Pr − n ln k) {S} ≤ that is−greater. − 1)) ,
- 9. Pr {S} = Pr {Si } i=k+1We approximate by integrals to bound this summation from above and below. By 2010 CS n the inequalities (A.12), we have k = 1068 Appendix A Summations i=k+1 n(i − 1) n n−1 n−1 1 1 1 k x dx ≤ i=k i = ≤ k n dx . k−1 x 1 n i=k+1 i − 1 f (x)Evaluating these deﬁnite integrals gives us the bounds k n−1 1k = k . (ln n − ln k) ≤ Pr {S} i=k i (ln(n − 1) − ln(k − 1)) , n ≤n nwhich provide a rather tight bound for Pr {S}. Because we wish to maximize our We approximate by integrals to bound this summation from above … below. By and f (m+1) f (m+2) f (n–2) f (n–1) f (m) f (n) …probability of success, let us focus on choosing the value of k that maximizes the the inequalities (A.12), we havelower bound on Pr {S}. (Besides, the lower-bound expression is easier to maximize x … …than the upper-bound n−1 1 n 1 expression.) Differentiating themexpression (k/n)(ln n −ln k) n–1 n n−1 1 –1 m m+1 m+2 n–2 n+1with respect to dx we obtain≤ k, ≤ dx . (a) k x i=k i k−1 x1 (ln n −Evaluating. these deﬁnite integrals gives us the bounds ln k − 1) f (x)n k k (ln n − ln k) ≤ Pr {S} ≤ (ln(n − 1) − ln(k − 1)) , n n which provide a rather tight bound for Pr {S}. Because we wish to maximize our probability of success, let us focus on choosing the value of k that maximizes the f (m+1) f (m+2) f (n–2) f (n–1) lower bound on Pr {S}. (Besides, the lower-bound expression is … easier to maximize f (m) f (n) … than the upper-bound expression.) Differentiating the expression (k/n)(ln n −ln k) x with respect to k, we obtain m –1 m m+1 m+2 … … n–2 n–1 n n+1 (b) p325 1 (ln n − ln k − 1) . n Copyright© 2010 tniky1 All rights reserved. Figure A.1 Approximation of n Page 9 k=m f (k) by integrals. The area of each rectangle is shown within the rectangle, and the total rectangle area represents the value of the summation. The in- tegral is represented by the shaded area under the curve. By comparing areas in (a), we get
- 10. nLet Pr {S}j )== max{Si } {Bji }{score(i)} denotePr {Smaximum score among appli M( probability1≤i≤ is clearly 1/n, since thethe } =isPr {B likely to be Pr {B } The Pr Pr maximum equally 2010 CS any one of the n positions. For event Oi to occur,i the maximumi value in}po- in ∩ Oi = ithrough j . 1Let i=k+1 S be the event that we succeed in choosing the best-q sitions through i − 1 must be in one of the ﬁrst k positions, and it is equally napplicant,=and let k iofbe the−event thatConsequently, Pr {Oi } = k/(i − 1) iandis clearly likely to be in any 1) these i 1 positions. we succeed when Pr {B } S The probability the best-qualiﬁedcant is the n(i − = k/(n(i interviewed. Since in any i=k+1 Pr {Si } ith one− 1)). Using equation (5.13), thehave one of the n positions. ha we various Si are disjoint, we F k n n 1 nPr {S} = = i=1 Pri {S1 }. Noting i sitions 1 through − best-qualiﬁ that we never succeed wheni the 1 must be Pr {S} n i=k+1 −Pr {Si } =plicant is one n−1i=k+1 ﬁrst k, we have that likely}to be forany of these. i, − 1 of the = 1,2,•••,k Pr {Si = 0 in i = 1, 2, . . k. Th k 1obtain = n i=k i n. k = k+1,•••,n Pr {Si } = k/(n(i − 1)). Using eq = n n(i − 1) i=k+1 nPr {S} approximatePr {Si } .1to bound this summation from{S} and below. By Pr {S } We = by integrals k n Pr above = = the inequalities (A.12), we have i i=k+1 n i=k+1 i − 1 n n−1 i=k+1 1/k + 1/(k+1) + 1/(k+2) + ••• + 1/(n-‐1) 1 1 n−1 n−1 1 We now≤compute 1 .x{Si .}. In order to succeed when the best-qualiﬁed k x dx = i=k i k≤ Pr dx k−1 n k apis the ith one, two things mustus the bounds First, the= n i=k i Evaluating these deﬁnite integrals gives happen. best-qualiﬁed applicant m n(i − 1) i=k+1the algorithm min position i, an event which bounddenote by BfromSecond, below. By k We approximate by integrals to we this summation i . above and k (ln n − ln k) ≤ Pr {S} ≤ (ln(n − 1) − ln(k − 1)) , nselect anyinequalities (A.12), we have positions k + 1 through ik− 1, which happens n the of the applicants in n 1 which provide a that k + 1 ≤ j ≤ i Because we wish to =for each nj1such rather1tight bound1 for Pr {S}.− 1, we ﬁnd that score( j ) < bestscore in maximize our probability of success, let us focus on choosing the value of k that maximizesi=k+1 i − 1 n the n−1 n−1 dx ≤ are unique, we. can ignore the possibility of score( j ) = bes ≤ dx (Because scores {S}.i (Besides, the lower-bound expression is easier to maximize lowerkbound on Pr k Pr{S} x k−1 x than the upper-bound must be the case that all of the n k n−1 1 i=kIn other words, it expression.) Differentiating the expression (k/n)(ln values score(k + 1) t −ln k)score(i − 1) are less than M(k); if any are greater = n p111 Evaluatingk, we obtain with respect to these deﬁnite integrals gives us the bounds . than M(k) we will 1instead i k k 1 Copyright© 2010 tniky1 All rights reserved. i=k Page 0 the index of−the .ﬁrst one (ln(n 1) − ln(k We use Oi to denote the event th (ln n(ln ln k − 1) ≤ Pr − n ln k) {S} ≤ that is−greater. − 1)) ,
- 11. k We i=k i k−1 approximate by integrals to bound this summation from above and below. B in any onethe inequalities (A.12), we For event Oi the bounds the maximum valu of the these deﬁnite integrals gives us to occur, Evaluating nn positions. have 2010 CS Pr {S} = Pr {Si } i −in ordering 1kthrough i=k+1 11positions in through the ﬁrstwhereas Bi depends is sitions of the valuesn−1 mustn−1 1 one of i − 1, k positions, and it o n be 1 k1 likely the value ink) ≤ Pr ≤ − (ln(n. − 1) − ln(k values in Pr {Oi } position whetherto n (ln nx− ln≤positioni ik−1 1greater thanConsequently,all other = k/(i be in any of these ≤ positions. the − 1)) , dx n {S} is dx i k nx k = − 1)). Using equation (5.13), we have Pr {Si } of the values n(i − 1) ordering = k/(n(i i=k+1in positions 1 through{S}.− 1 does not affect whet i=k Pr i Because we wish to maximiz which provide a rather tight bound for us the bounds Evaluating these deﬁnite integrals gives value in positionn i is greater than all of them, and the value of k position i do probability of success, let us focus on choosing the value in that maximize k n 1 k Pr {S} = k bound k) ≤ {S}. ≤ in(ln(n − lower-bound expression easier to can lower = ln the values k affect the≥ (ln n −ofon Pr}Pr− 1(Besides, the 1) − ln(k − 1)) , i − 1. isThus wemax {Si ordering Pri=k+1 i {S} n positions 1 through n i=k+1 n upper-bound expression.) Differentiating the expression (k/n)(ln n − than theto obtain equation (C.15) provide a rather tight bound for Pr {S}. Because we wish to maximize ou n−1 which n with respect 1 k to k, we obtain k . let random variables = of indicator us focus on choosing the value of k that maximizes th istic analysis and further usesn of =i Pr {B } Pr {O } . 117 Pr {Si } = Prprobabilityi } success, i = {Bi ∩ O i=k i 1 lower bound on Pr1) (Besides, the lower-bound expression is easier to maximiz 117− ln k − 1) {S}. (ln i=k+1 n(i − . n The probability Prn{Bi }by integrals to1/n, since the maximum is and below.−ln k n than the upper-bound expression.) Differentiating the expression equallynlikel We approximate is clearly bound this summation from above (k/n)(ln By of k n 0 1 with respect to k, we obtain k in any one to the we (A.12), we have event Oi bound on the probability derivative equal the inequalities see thatFor lower to occur, the maximum value = 1 0, positions. the sitions 1 through − ln ki1− 1. n−1 1 in one of the ﬁrst k positions, and it is e n i=k+1ed on the ln k = lnn ndx ≤ − 1 ≤ln(n/e) or, equivalently, when k = n/e. n (ln n i n−1 − must be 1 − 1 = 1)d whenlikely to be in any of these i − 1 positions. Consequently, Pr {O } = k/(i − probability dx . k xk n−1 i 1 i k−1 xtly, when{Siour k/(n(i − 1)).. Using= n/e, we will succeed in hiring our implementk } = = = strategy with k equation (5.13), we have n/e. i=k Pr k!! d applicant Evaluating these deﬁnite integrals gives us the boundsucceed in hiring probability at least 1/e. with our i=k i n n k [ k] Pr {S} ≥ n = (ln n − ln k){Si Pr {S} ≤ (ln(n − 1) − ln(k − 1)) , Pr ≤} k=n/e n We approximate by integrals to bound this summation from above and be i=k+1 which provide a rather tight bound for Pr {S}. Because we wish to maximize our the inequalities (A.12), welet us focus on choosing the value of k that maximizes the p111 probability of success, have n k 1/e =lowern−1 on Pr Copyright© 2010 tniky1 All rights reserved. {S}. (Besides, the lower-bound expression is easier to maximize bound n 1 than the upper-bound 1 i=k+1 1 n(i − 1) expression.) Differentiating the expression (k/n)(ln n1−ln k) n−1 Page 1
- 12. 116 Chapter 5 Probabilistic Analysis and Randomized Algorithms Pr {Si } = k/(n(i − 1)). Using equation (5.13), we have2010 CS n Pr {S} = ordering of the values in positions Pr {Si } ordering of the values in positions 1 through i − in position i Bi gre i=k+1 whether the value 1, whereas is de (whether the value in position i is greater than the valuesin positions ) TVn k ordering of the values in all other = ordering of the values in positions 1 in position −is greater than al i=k+1 n(i − 1) value through i i 1 does not affe value in position i is greater than all of them, and thethe values in value in posi • k n 1 affect the ordering of affect the ordering of the values in positions 1 through i − 1. Thus = equation (C.15) to obtain i − 1 equation (C.15) to obtain n i=k+1 – k n−1 1 10 Pr {Si } = Pr {Bi ∩ Oi } = Pr {Bi } Pr = . Pr {Si } = Pr {Bi ∩ On}i=k iPr {Bi } Pr {Oi } . i = – (The probability Pr {B ) is clearly 1/ i} The probability Pr {Bi } by integrals to bound this summation from aboveequal We approximate is clearly 1/n, one ofthe maximum is and b in any since the n positions. For in any onethe inequalities (A.12), we For event through 0.1 1the maximum of the n positions. sitions 1 Oi1/10 occur, must be in have to = i − sitions 1 through i − 1 mustn−1 likely to be in any of k positions,pos n n−1 be in one of the ﬁrst these i − 1 an 1 1 1 dx of ≤ positions. Consequently, Pr {Oi } = (n=10) dx . likely to be in any ≤ these i − 1Pr {S } = k/(n(i − 1)). Using equat k k x i k−1 x i Pr {Si } = k/(n(i − 1)). Using equation (5.13),k=3 have i=k !(^^;) we Evaluating these deﬁnite integrals gives us the nbounds 0.3611 Pr{S} n = k k {S} = Pr Pr {S} ≥ (ln n − ln k) ≤ }Pr {S} ≤ (ln(n − 1) − ln(k Pr{S} , 0.3665 Pr {Si k=4 Pr {Si } − i=k+11)) n i=k+1 n n which provide a rather/e 10/(2.7182 Pr {S}. .679 kwe wish to maxi n k = n tight bound for ) 3 Because = probability of success, let us focus on= k choosing the value of Page 12 maxim n(i − 1)k that = Copyright© 2010 tniky1 All rights reserved. i=k+1 lower bound on Pr {S}. (Besides, the lower-bound expression is easier to m
- 13. 2010 CS n k k/n lgn lgk logn-logk Pr{S} 10 1 0.1 2.302585093 0 2.302585093 0.230258509 10 2 0.2 2.302585093 0.693147181 1.609437912 0.321887582 10 3 0.3 2.302585093 1.098612289 1.203972804 0.361191841 10 4 0.4 2.302585093 1.386294361 0.916290732 0.366516293 10 5 0.5 2.302585093 1.609437912 0.693147181 0.34657359 10 6 0.6 2.302585093 1.791759469 0.510825624 0.306495374 10 7 0.7 2.302585093 1.945910149 0.356674944 0.249672461 10 8 0.8 2.302585093 2.079441542 0.223143551 0.178514841 10 9 0.9 2.302585093 2.197224577 0.105360516 0.094824464 10 10 1 2.302585093 2.302585093 0 0 Copyright© 2010 tniky1 All rights reserved. Page 13

No public clipboards found for this slide

Be the first to comment