简体   繁体   中英

Hashtable Collision Handling

I have a hashtable with 11 buckets. And have to decide between the hashfunktion

h(k)= k mod 6 or h(k)= k mod 10

Which one is the best solution? I think it is h(k)= k mod 10 because with h(k)= k mod 6 there can point 2 or 3 keys to the same bucket.

And I thought when you have h(k)= k mod 10 the minimum of the buckets have to be 10.

thanks for help.

If you must decide between these two functions, mod 10 wins, because it leaves only one bucket unused, as opposed to five buckets that would be unused if you go with mod 6.

Ideally, though, you should use mid 11 for an eleven-bucket hash table, because it spreads hash codes among all available buckets.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM