时空权衡——哈希法(Time/Space Tradeoff - Hashing)
哈希法简介(Introduction)
Hashing is a standard way of implementing the abstract data type “dictionary”, which is a set with the operations of searching, insertion, deletion, initialisation and rehashing. The elements of this set can be anything, such as numbers, characters, character strings, etc.
The element above is called the key. Hashing is based on this idea of distributing keys among a one-dimensional array H[0..m-1] called a hash table. The method for the distribution is called hash function. The function assigns an integer between 1 to m, called hash address, to a key. e.g. h: key -> {1..m}
哈希函数(Hash Function)
If keys are integers and the size of a hash table is m, we can denote h(n) = n mod m. Actually, the has