The 3 most commonly used hash functions:
1. Division hashing: By taking K divided by the remainder of M, to map the keyword K to one of the M slots, that is, the hash function is:
H (k) = k mod m
2. Multiplication hashing: First, the keyword K is multiplied by the constant A (0<a<1), and the fractional part of Ka is extracted, then, by multiplying the value by M, the bottom of the result (that is, the integer part) is taken. The hash function can be expressed as:
H (k) =⌊m (KA mod 1) ⌋
3. Global hashing method (Universal hashing)
There are two common ways to resolve conflicts:
1. Linking method (chaining): all elements that are hashed into the same slot are stored in a linked list. Each slot has a pointer to the head of the linked list that consists of all the elements that are hashed into the slot. If no such element exists, the pointer is empty. If the link method uses a doubly linked list, the worst-case run time for the delete operation is the same as the insert operation, which is O (1), while the average time for the next successful lookup requires θ (1+α). α is the filling factor.
2. Open addressing Method (openaddressing): All elements are stored in a hash table. Therefore, the case for dynamic collection size n is not greater than the hash table size, that is, the loading factor does not exceed 1. Otherwise, a hash table overflow may occur. There are three techniques commonly used to calculate the detection sequence in open addressing: linear detection, two detection, and dual detection.
The hash function of the hash table, what are the conflict resolution methods