简体   繁体   中英

How do I keep load factor small in my hash table?

I'm learning about hash tables and quadratic probing in particular. I've read that if the load factor is <= 0.5 and the table's size is prime, quadratic probing will always find an empty slot and no key will be accessed multiple times. It then goes on to say that, in order to ensure efficient insertions, I should always maintain a load factor <= 0.5. What does this mean? Surely if we keep adding items, the load factor will increase until it equals 1 whether we want it to or not. So what is implied when my textbook says I should maintain a small load factor?

这意味着在某些时候(当你在这种情况下超过0.5的负载系数时),你将不得不分配一个新表(它更大一些因素,可能是1.5或2,然后四舍五入到最近的素数)并将旧表中的所有元素复制到其中(这不是直接复制,项目的新位置通常与旧位置不同)。

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