Hash Table method of dealing with conflict

1. Open addressing

Linear probe
Hi = (Hash (key) + di) mod m (1≤i <m)
wherein:
the Hash (Key) is a hash function
and m is the length of the hash table
di increments the sequence 1,2, ......, m-1 and di = i
Secondary probe
Hi = (Hash (key) ± di) mod m
where:
the Hash (Key) is a hash function
and m is the length of the hash table, m is a requirement 4k + 3 prime number (k is an integer)
DI 12 increments sequence , -12,22, -22, ......, q2 , -q2 and q≤1 / 2 (m-1)
Double hash function
Hi = (Hash (key) + i * ReHash (key)) mod m (i = 1,2, ......, m-1)
wherein:
the Hash (Key), rehash (Key) is a two hash function,
m hash table length

2. zipper law

Provided hash function hash address field is obtained in the interval [0, m-1], to each hash address as a pointer to a chain, i.e., allocation pointer array elemType eptr is [m];Establish m empty list, A hash function to the key conversion, is mapped to the same hash address i synonyms are added to the eptr is [i] point to the list.

3. Establish a common overflow area

Hashing the hash function to generate the set of addresses is provided to [0, m-1], is assigned two tables:
a base table ElemType base_tbl [m]; each unit can hold only one element;
aOverflow table ElemType over_tbl [k]; Long key corresponding to the hash address conflict in the base table, then all such elements shall be stored in the table. When looking for a given kx value calculated by the hash function hash address i, and comparison to the base table base_tbl [i] units, if equal, the search is successful; otherwise, then overflow lookup table.

Published 32 original articles · won praise 0 · Views 606

Guess you like

Origin blog.csdn.net/qq_28133013/article/details/104377736