chap 2 66 ross

chap 2 66 ross - CS5314 Randomized Algorithms Homework 2...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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 median-finding 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 median-finding 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

Page1 / 5

chap 2 66 ross - CS5314 Randomized Algorithms Homework 2...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online