A few questions about Hash Tables

I read a lot about Hash Tables and how to implement it in C, and I think I have almost all the concepts in my head, so I can start coding my own, I have a couple of questions that I still don't understand.

As a link, I read this: http://eternallyconfuzzled.com/jsw_home.aspx

1) As I said on the site above, it is recommended to use two or a prime number for the size of the hash table. This is basically an array, and the array has a fixed size, so I can quickly find the value I'm looking for. I cannot declare a small array if I have a large input because it does not fit, and I cannot declare a very large array if my input data is not that big reason why it lost memory.

What is the optimal size for a hash table? What should I base my decision on?

2) In addition, there are several hash functions on this site that I have not read yet. It also states that it is always better to use a well-known algorithm and collapse your own. And I can do just that, I will choose one of this site and run it in my code and see if it minimizes collisions based on my input data.

What bothers me how do I manage a range of hashes? The hash cannot return and the integer is larger than the size of the hash table, or we will have a serious problem. How can I handle this?

+3
source share
2 answers

1) , , - - , , , . :

- , 0 0,7 . , .

, Java (, , ) , .

2) modulo (%), . .

+3

-. , , ; 70%, . , - , , 60%. , .

, , , :

, -, , . ( , . , , .)

-, , , . , , , ?

+1

Source: https://habr.com/ru/post/1733716/


All Articles