I need to implement a program, which will insert numbers from input to hash table. I want to use chaining method to avoid collisions. The program must have a function to resize hash table. My question is, how to count load factor, and when the hash table should be resized?
Asked
Active
Viewed 890 times
1
-
1I guess all the answers are here https://en.wikipedia.org/wiki/Hash_table#Key_statistics – Support Ukraine Nov 02 '18 at 14:02
-
and here https://en.wikipedia.org/wiki/Hash_table#Dynamic_resizing – Support Ukraine Nov 02 '18 at 14:03
-
In case of Java, the load factor for `HashMap` is an argument provided by user (with DEFAULT_LOAD_FACTOR = 0.75f), so you theoretically leave the decision up to user, how often do they want to re-hash. – Adam Kotwasinski Nov 02 '18 at 14:06
-
@4386427 Thank you. But I still missing the information when to resize the table. What value should the load factor take? Adam Kotwasinski mentioned, load factor in Java is 0.75 because of good tradeoff probably. I will code it in C, so I am looking for a general value. – A.Cabb Nov 02 '18 at 14:21