# sol9 - CS 70 Fall 2010 Discrete Mathematics and Probability...

• Notes
• 16

This preview shows pages 1–3. Sign up to view the full content.

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 Ω 0 from the first answer, by tracking how many objects get hashed to each table entry/bucket. So now, Ω 0 = { ( b 1 , b 2 , b 3 ) : b i ∈ { 0 , 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, Ω 0 = ( 0 , 0 , 3 ) ( 1 , 1 , 1 ) ( 0 , 1 , 2 ) ( 1 , 2 , 0 ) ( 0 , 2 , 1 ) ( 2 , 0 , 1 ) ( 0 , 3 , 0 ) ( 2 , 1 , 0 ) ( 1 , 0 , 2 ) ( 3 , 0 , 0 ) 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 ω Ω 0 . 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 , 0 )] = 3 27 since there are ( 3 1 ) ways of choosing which of the three objects gets hashed CS 70, Fall 2010, Soln 9 1

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

to bucket 1, and each such way contributes a probability of ( 1 3 ) 3 = 1 27 to Pr [( 1 , 2 , 0 )] . The probability assignment for Ω 0 is: ω Pr [ ω ] ω Pr [ ω ] ( 0 , 0 , 3 ) 1 27 ( 1 , 1 , 1 ) 6 27 ( 0 , 1 , 2 ) 3 27 ( 1 , 2 , 0 ) 3 27 ( 0 , 2 , 1 ) 3 27 ( 2 , 0 , 1 ) 3 27 ( 0 , 3 , 0 ) 1 27 ( 2 , 1 , 0 ) 3 27 ( 1 , 0 , 2 ) 3 27 ( 3 , 0 , 0 ) 1 27 You can check for yourself that these probabilities indeed sum to 1. (b) Let X be the length of the linked list at entry 1 of the table. Write down X explicitly as a function on the sample space mapping to the real line (either in a figure as in class or as a list). Compute and plot the distribution and expectation of X . Answer 1: For the sample space Ω , we show each outcome ω and the value X ( ω ) for that outcome: ω X ( ω ) ω X ( ω ) ω X ( ω ) ( 1 , 1 , 1 ) 3 ( 1 , 1 , 2 ) 2 ( 1 , 1 , 3 ) 2 ( 1 , 2 , 1 ) 2 ( 1 , 2 , 2 ) 1 ( 1 , 2 , 3 ) 1 ( 1 , 3 , 1 ) 2 ( 1 , 3 , 2 ) 1 ( 1 , 3 , 3 ) 1 ( 2 , 1 , 1 ) 2 ( 2 , 1 , 2 ) 1 ( 2 , 1 , 3 ) 1 ( 2 , 2 , 1 ) 1 ( 2 , 2 , 2 ) 0 ( 2 , 2 , 3 ) 0 ( 2 , 3 , 1 ) 1 ( 2 , 3 , 2 ) 0 ( 2 , 3 , 3 ) 0 ( 3 , 1 , 1 ) 2 ( 3 , 1 , 2 ) 1 ( 3 , 1 , 3 ) 1 ( 3 , 2 , 1 ) 1 ( 3 , 2 , 2 ) 0 ( 3 , 2 , 3 ) 0 ( 3 , 3 , 1 ) 1 ( 3 , 3 , 2 ) 0 ( 3 , 3 , 3 ) 0 Since each point ω Ω has the same probability of 1 27 , we can simply count the number of points which are mapped to k by X
This is the end of the preview. Sign up to access the rest of the document.
• Spring '08
• Probability theory, soln

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern