Unformatted text preview: when a single key is hashed A: the address is not chosen B: the address is chosen P(B) = 1/N = b P(A) = (N-1)/N = 1 1/N = a
r-x x r 1 1 p ( x) = 1 - x N N A given address, there are x records assign to it where r is the number of records to be stored. 1 r When N , r , binomial r, poisson N N 42 Predicting the Distribution of Records The Poisson function applied to hashing
(r / N ) x e p( x) = x!
- r N where
N = # of available addresses r = # of records to be stored X = # of records assigned to a given address P(x) = prob. that a given address will have x records assigned to it after the hashing functions has been applied to all r records. 43 Predicting the Distribution of Records E.g. There are 1000 addresses (N=1000) and 1000 records whose keys are to be hashed to the addresses. (r=1000) Sol: r / N =1 10 e -1 = 0.368, p(0) = 0! 12 e -1 = 0.184, p ( 2) = 2! 11 e -1 = 0.368 p (1) = 1! 13 e -1 = 0.061 p (3) = 3! 44 Predicting the Distribution of Records Expect # of addresses with x records assign to them is Np(x) E.g. N = 10000, r = 10000 # of addresses with no records assigned is 10000 x p(0) = 3679 How many addresses should have one, two, and three records assigned, respectively? 10000 x p(1) = 3679 (no synonyms or no collision) 10000 x p(2) = 1839 (exist 1839 overflow records) 10000 x p(3) = 613 (exist 2 x 613 = 1226 overflow records) Note: We must try to reduce the # of overflow records 45 How much extra memory should be used? # of records packing density = # of spaces E.g. Suppose that 1000 addresses are allocated to hold 500 records in a randomly hashing file, and that each address can hold one record. The packing density for the file is 500 r = = 0. 5 N 1000 How many address should have no one record assigned? (0.5) 0 e -0.5 Np (0) = 1000 = 607 0!
View Full Document
This note was uploaded on 10/25/2009 for the course EE 2011 taught by Professor Denny during the Spring '09 term at National Tsing Hua University, China.
- Spring '09