Lecture9

Lecture9 - Lecture 9 Successful Search Expected time to...

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

1 102 Successful Search Expected time to find i -th element = time to insert i -th element Assume that the key being searched for is equally likely to be any one of the keys stored. Conditioned on “key was the i -th element inserted” » Conditional expectation = » Expectation: Intuition: need to search 1/2 of a list on the average. 1 1 i m    1 11 (1 ) 22 2 Pr[i-th element inserted] [time conditioned on i] 1 1 ( 1 ) n i nn ii m nm nm E i i m O       Lecture 9, Oct 19 2010 103 Choosing Hash Functions Mostly black magic… division method: h(k)=k mod m » Do not use m=2 p (will not use all the bits) » choose m=prime not too close to power of 2 or 10. Multiplication method: » choose m 2 p , 0 < A < 1 , not too close to 0 or 1 . » If m=2 P , then all we do is scramble by multiplication, and choose p bits to the left of binary point.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 4

Lecture9 - Lecture 9 Successful Search Expected time to...

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

View Full Document
Ask a homework question - tutors are online