Hash list, also called hash table, English name is Hashtable. is a sub-knowledge point in the "find" directory within the data structure. If the hash table does not conflict, the hash lookup is the most efficient of all the lookups we have described. Because the hash lookup time Complexity is O (1). Unfortunately, there is no conflict in the hash table is only an ideal, the actual application of conflict is unavoidable.
Method of constructing hash function: 1. Direct addressing method. A linear function value that takes a keyword is a hash address. 2. Digital Analysis method. 3. Square method. 4. Folding method. 5. Except for leaving the remainder of the hair. 6. Random number method. The details of the method can be referred to the "Dahua data Structure" p356-p360.
The methods for dealing with hash conflicts are: 1. Open addressing law. To be blunt, when F (key1) ==f (Key2), that is, two different keywords through the hash function to calculate the position of the same time, first occupy the position of the affirmation occupy, the later one can only occupy its next temporary position, if the pro position has been accounted for the next temporary position. 2. hash function method. That is to say the remainder, folding, square, and so on in front of the method are used. Each time a hash address conflict occurs, a hash function is replaced, and there is always one that can resolve the conflict. 3. Chain address method. Stores all keywords as synonyms in a single linked list, which is called a synonym child table, where only the head pointers for all synonym child tables are stored in the hash table. 4. Public overflow Zone law. Creates a common overflow area for all conflicting keywords.
For the code of the hash list lookup implementation and its analysis, can refer to "Big talk data Structure" p365-p367 content, the introduction is easy to understand.