Hash table Lookup Performance Analysis Summary

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.