Open Class Address:
Http://open.163.com/movie/2010/12/3/A/M6UTT5U0I_M6V2TGI3A.html
Full Domain Hash
Birth:
The fundamental flaw of the hash: for any hash function, there is a bad health set, so that all the health will be hashed into the same slot, then how to solve this situation? How do I prevent a key set from ever having a poor performance? How do you prevent competitors from using this key set to reduce your performance? A word to solve the problem--random!
The whole-domain hash method is to randomly select a hash function h (not each operation will choose a hash function, but a hash table to build a random selection, after the selection of this hash table all operations are based on this hash function, this method can prevent the competitor design a key set of ulterior motives, It is also possible to avoid some key sets that will always lead to poor performance, and if so, rebuild a table! )
Defined:
Set u as the whole domain of the key, H is the finite set of hashes, h each hash function h maps the set U to the M position of the hash table, if the hash table satisfies: two values in U x, y x≠y {h∈h:h (x) =h (y)}=| H|/m, then H is the whole domain.
| H| means the number of hash functions in the whole domain, then take a function h from the inside, the probability that the function will hash x and Y to the same position is 1/m, that is, these functions are uniform functions.
Hash Function Group Construction one of the following methods :
Take m as a prime number, take the random number A is r+1 bit m binary, expressed as <A0,A1,..., ar> (where 0 <= Ai <= m-1 is randomly selected), then the hash function H[a] (K) is defined as:
H[a] (K) = sum {Ai * Ki | i =0, 1, ..., m-1} mod m
Prove:
Proof of theorem
Full Hash
the basic flaw of hashing, even if the whole domain hash is constructed, is not necessarily able to solve the problem of bad keyset input, can you find a perfect solution?
can you guarantee that the complexity of finding in any case is in θ (1)? And the hash table is not too big to meet N=o (m)
now to do the reasoning, if we ask for any number x in the hash table, the expected number of collisions, less than 1
in the case of uniform hashing, the likelihood of collisions is 1/m for each number, so
cn2*1/m=n (n-1)/2m <1 so M>n (n-1)/2 that is, M is the magnitude of the square of N, so an ordinary hash table is not possible to accomplish this task unless the hash table is constructed very large.
The solution is to construct a double-layered hash structure, where the bottom of the hash table is used to hold the second level of the entry pointer and the hash function used, and the second layer is the data element that proves slightly
Full domain hash and full hash--Introduction to MIT Algorithm Open class