solution1 - Solutions to Assignment 1 Anindya De Y4062...

Info iconThis preview shows pages 1–3. 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: Solutions to Assignment 1 Anindya De Y4062 e-mail: { anindya } @cse.iitk.ac.in February 5, 2008 Randomized Select Expected Number of Comparisons Solution: Let X be a random variable which denotes the number of comparisons made during any random experiment. Let h a 1 ,a 2 ,a 3 ,...,a j i be the elements of set S arranged in increasing order. Let X ij be a random variable which takes value 1 if and only if a i is compared to a j during the random experiment. Without loss of generality (and to avoid over-counting), we shall assume i < j . It is trivial to see X = 1 i<j n X ij . As X ij takes only values 0 and 1, hence we can say that Pr [ X ij = 1] = E [ X ij ]. Hence, using linearity of expectation, we can say E [ X ] = X 1 i<j n Pr [ X ij = 1] (1) There are three possibilities for i and j . 1. 1 i < j k- In this case, note that X ij = 1 iff the first number to be randomly selected from { a i ,a i +1 ,...,a k- 1 ,a k } is one of a i or a j . Since the numbers are selected uniformly randomly, the probability is 2 k- i +1 . 2. k i < j n- In this case, note that X ij = 1 iff the first number to be randomly selected from { a k ,a k +1 ,...,a j- 1 ,a j } is one of a i or a j . Since the numbers are selected uniformly randomly, the probability is 2 j- k +1 . 3. 1 i < k < j n- In this case, note that X ij = 1 iff the first number to be randomly selected from { a i ,a i +1 ,...,a j- 1 ,a j } is one of a i or a j . Since the numbers are selected uniformly randomly, the probability is 2 j- i +1 . Hence, Eqn 1 can be rewritten as E [ X ] = X 1 i<j k Pr [ X ij = 1] + X k i<j n Pr [ X ij = 1] + X 1 i<k<j n Pr [ X ij = 1] The first sum is X 1 i<j k Pr [ X ij = 1] = X 1 i<j k 2 k- i + 1 = X 1 i<k 2( k- i ) k- i + 1 < 2 k The second sum is X k i<j n Pr [ X ij = 1] = X k i<j n 2 j- k + 1 = X k<j n 2( j- k ) j- k + 1 < 2( n- k ) 1 The third sum is X 1 i<k<j n Pr [ X ij = 1] = X 1 i<k<j n 2 j- i + 1 = k- 1 X i =1 n X j = k +1 2 j- i + 1 To upper bound the inner sum, we see that n X j = k +1 2 j- i + 1 < Z n k 2 x- i + 1 dx = 2ln n- i + 1 k- i + 1 Hence, we can conclude that X 1 i<k<j n Pr [ X ij = 1] < k- 1 X i =1 2ln n- i + 1 k- i + 1 = 2ln Q k- 1 i =1 ( n- i + 1) Q k- 1 i =1 ( k- i + 1) ! It is trivial to see that the denominator in the last term is Q k- 1 i =1 ( k- i + 1) = k !. Hence, we can say that 2ln Q k- 1 i =1 ( n- i + 1) Q k- 1 i =1 ( k- i + 1) ! < 2ln Q k i =1 ( n- i + 1) k ! ! = 2ln ( n- k )! Q k i =1 ( n- i + 1) k !( n- k )! ! = 2ln n k < 2 n ln2 The last inequality follows from the fact that ( n k ) < 2 n (This follows from n k =0 ( n k ) = 2 n ). Hence adding all the three components of comparisons, we get E [ X ] = X 1 i<j k Pr [ X ij = 1]+ X k i<j n Pr [ X ij = 1]+ X 1 i<k<j n Pr [ X ij = 1] < 2 k +2( n- k )+2 n ln2 < 3 . 39 n Hence, we have proven that the total number of comparisons in...
View Full Document

This note was uploaded on 11/24/2009 for the course CS CS648 taught by Professor Surenderbaswana during the Spring '08 term at University of Massachusetts Boston.

Page1 / 8

solution1 - Solutions to Assignment 1 Anindya De Y4062...

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

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