sol9 - CS 70 Discrete Mathematics and Probability Theory...

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: CS 70 Discrete Mathematics and Probability Theory Fall 2010 Tse/Wagner Soln 9 1. (16 pts.) A Very Small Example of Hashing Suppose we hash three objects randomly into a table with three (labelled) entries. We are interested in the lengths of the linked lists at the three table entries. (a) List all the outcomes in the sample space of the experiment. How many of them are there? Answer 1: The outcomes are = ( 1 , 1 , 1 ) ( 1 , 1 , 2 ) ( 1 , 1 , 3 ) ( 1 , 2 , 1 ) ( 1 , 2 , 2 ) ( 1 , 2 , 3 ) ( 1 , 3 , 1 ) ( 1 , 3 , 2 ) ( 1 , 3 , 3 ) ( 2 , 1 , 1 ) ( 2 , 1 , 2 ) ( 2 , 1 , 3 ) ( 2 , 2 , 1 ) ( 2 , 2 , 2 ) ( 2 , 2 , 3 ) ( 2 , 3 , 1 ) ( 2 , 3 , 2 ) ( 2 , 3 , 3 ) ( 3 , 1 , 1 ) ( 3 , 1 , 2 ) ( 3 , 1 , 3 ) ( 3 , 2 , 1 ) ( 3 , 2 , 2 ) ( 3 , 2 , 3 ) ( 3 , 3 , 1 ) ( 3 , 3 , 2 ) ( 3 , 3 , 3 ) where ( a 1 , a 2 , a 3 ) means that the i th object is hashed to table entry a i . There are 27 outcomes. Answer 2: The set of outcomes of this experiment is = { ( a 1 , a 2 , a 3 ) : a 1 , a 2 , a 3 { 1 , 2 , 3 }} , where a i denotes the table entry/bucket where object i is hashed to. Hence, | | = 3 3 3 = 27. Answer 3: We can create a different sample space from the first answer, by tracking how many objects get hashed to each table entry/bucket. So now, = { ( b 1 , b 2 , b 3 ) : b i { , 1 , 2 , 3 } , b 1 + b 2 + b 3 = 3 } , where b i denotes the number of objects that are hashed to table entry/bucket i . More explicitly, = ( , , 3 ) ( 1 , 1 , 1 ) ( , 1 , 2 ) ( 1 , 2 , ) ( , 2 , 1 ) ( 2 , , 1 ) ( , 3 , ) ( 2 , 1 , ) ( 1 , , 2 ) ( 3 , , ) There are 10 outcomes. Comment: In Answers 1 and 2, we have Pr [ ] = 1 | | = 1 27 . for all . Therefore, the probability space for Answers 1 and 2 is uniform. In contrast, the probability assignment for Answer 3 is not uniform. The probabilities are no longer the same for all . For example, Pr [( 1 , 1 , 1 )] = 6 27 since any of the 3! = 6 ways of permuting the three objects among the three table entries would contribute a probability of ( 1 3 ) 3 = 1 27 to Pr [( 1 , 1 , 1 )] . Similarly, Pr [( 1 , 2 , )] = 3 27 since there are ( 3 1 ) ways of choosing which of the three objects gets hashed CS 70, Fall 2010, Soln 9 1 to bucket 1, and each such way contributes a probability of ( 1 3 ) 3 = 1 27 to Pr [( 1 , 2 , )] . The probability assignment for is: Pr [ ] Pr [ ] ( , , 3 ) 1 27 ( 1 , 1 , 1 ) 6 27 ( , 1 , 2 ) 3 27 ( 1 , 2 , ) 3 27 ( , 2 , 1 ) 3 27 ( 2 , , 1 ) 3 27 ( , 3 , ) 1 27 ( 2 , 1 , ) 3 27 ( 1 , , 2 ) 3 27 ( 3 , , ) 1 27 You can check for yourself that these probabilities indeed sum to 1....
View Full Document

This note was uploaded on 12/08/2010 for the course CS 70 taught by Professor Papadimitrou during the Fall '08 term at University of California, Berkeley.

Page1 / 16

sol9 - CS 70 Discrete Mathematics and Probability Theory...

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