Verbatim large column https://www.dazhuanlan.com/2019/08/26/5d634caaa6a11/
Direct addressing table
Direct addressing table (direct-address table) is a generalization of the common concept of an array of elements in the table to access directly through the key, when the global key of U is relatively small, direct addressing is a simple and effective technique.
Hash table
Direct addressing table drawback is obvious: When the key global U large size of the table | U | will take up a lot of storage space.
Hash (hash) and the intent is to put together randomly mixed, is an extremely effective and practical techniques in computer science, this technique hash function , the input of any length, converted to an output (hash value of a fixed length ). This conversion is a compression map (output space much smaller than the input space).
Hash table (hash table) is a data structure implemented by hashing dictionary operations (INSERT, SEARCH, DELETE), alternative by directly addressing the array hash (key through a hash function maps to a storage location, i.e., slot ( slot)), makes it possible to $ O (1) accessible from anywhere within the table $ time.
conflict
Conflict (Collision): refers to two key mapped to the same slot
resolve the conflict: There are two ways to resolve the conflict, one is the link method (Chaining), the other is open addressing method (open addressing )
Hash function
- Division hash function (heuristic)
$ H (K) = K MOD m $ - Multiplication hash function (heuristic)
$ H (K) = m lfloor (kA MOD. 1) $ rfloor - Global hash function (randomization technique)
randomly selecting a hash function, makes it independent of the keywords stored
Links Law
In the link process, the hash to the same slot on the element are stored in a linked list, and stores the list into the slot in the header
Addressing French Open
In open addressing method, all the elements are stored in a hash table, each entry is either NIL or contain a dynamic element of the set, when looking for an element, will probe all entries until you find the target element or final identify the target element not in the table. In open addressing method, the hash table might be filled.
Probe sequence (probe sequence): $ (h (k, 0), h (k, 1), ..., h (k, m-1)) $, i.e. $ (0,1, ..., m- 1) $ a permutation.