Hash Table embarrassment

Source: Internet
Author: User
Due to the cache hit rate, the performance of the hash table is generally better than that of the Red/black tree. Even if there are only 32 elements, 5 random memory accesses are required. Random memory access is unfriendly to CPU cache. The biggest drawback of a hash table is that when the data volume is difficult to estimate, you cannot set a suitable bucket. The number of elements may be 10 or 10000. Here are several ideas: 1. set the default bucket value to around 100, and then enable automatic expansion of the hash table. The disadvantage is that the performance is affected during expansion. 2. Combined with the business, each time 10000 buckets are provided, the disadvantage is that the memory is wasted and cannot be processed in extreme situations such as million. 3. Convert the list of hash tables into hash tables. The disadvantage is that the structure is complex and the hash speed is slow for multiple times. Overall, solution 1 is better.

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.