This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CS5314 Randomized Algorithms Homework 2 (Suggested Solution) 1. A fixed point of a permutation π : [1 ,n ] → [1 ,n ] is a value for which π ( x ) = x . Find the variance in the number of fixed points of a permutation chosen uniformly at random from all permutations. Hint: Let X i be an indicator such that X i = 1 if π ( i ) = i . Then, ∑ n i =1 X i is the number of fixed points. You cannot use linearity to find Var [ ∑ n i =1 X i ], but you can calculate it directly. Ans. For each i , we have E [ X i ] = Pr( X i = 1) = 1 /n and E [ X 2 i ] = Pr( X 2 i = 1) = 1 /n. For any i,j with i 6 = j , we have E [ X i X j ] = Pr( X i X j = 1) = Pr( X i = 1 ∩ X j = 1) = Pr( X i = 1)Pr( X j = 1  X i = 1) = 1 n ( n 1) . Let X be the number of fixed points. So, X = ∑ n i =1 X i , and E [ X ] = ∑ n i =1 E [ X i ] = 1. Then, we have Var[ X ] = E [ X 2 ] ( E [ X ]) 2 = E ˆ n X i =1 X i ! 2  1 = n X i =1 E [ X 2 i ] + X i 6 = j E [ X i X j ] 1 = n · 1 n + n ( n 1) · 1 n ( n 1) 1 = 1 . 2. Generalize the medianfinding algorithm to find the k th largest item in a set of n items for any given value of k . Prove that your resulting algorithm is correct, and bound its running time. Ans. We first consider the case where k ≤ n/ 2. For this case, we scan the n items and obtain the minimum value, say, t . Then, we add n 2 k + 1 items to the set of n items, each item having a value equal to t . It is easy to check that the k th largest item among the original n items will be the median of the new set of 2 n 2 k + 1 items. Therefore, we can apply the medianfinding algorithm for the new set to obtain the desired k th largest item of the original set. The running time is O ( n ). For the case where k > n/ 2, we proceed by adding items with maximum value instead. The running time for this case is also O ( n ). 3. The weak law of large numbers state that, if X 1 ,X 2 ,X 3 ,... are independent and identically distributed random variables with finite mean μ and finite standard deviation σ , then for any constant ε > 0 we have lim n →∞ Pr fl fl fl fl X 1 + X 2 + ··· + X n n μ fl fl fl fl > ε ¶ = 0 ....
View
Full
Document
This note was uploaded on 09/24/2009 for the course IE 221 taught by Professor Georgewilson during the Spring '08 term at Lehigh University .
 Spring '08
 GeorgeWilson

Click to edit the document details