How to choose a hash table size?

Suppose I have 200,000 words, and I'm going to use hash*33 + word[i]as a hash function, what should be the size of the table for optimization, for a minimal memory / page problem?

The platform used is C (version c99),

words - English words char, ASCII values

One-time hash table initialization (link list style buckets),

used to search for the next, for example, to search in a dictionary.

After the collision, this word will be added as a new node to the bucket.

+4
source share
1 answer

75% ( 70%) ( ) O (1) . , -.

, 266 700 ( 75%), 285 700 70%. .

, - - , .

-, hash*33 + word[i]. Jenkins hash, , , , .

. 500 000 40%, -. . , 1 20%, , .

: - .

, . , (.. ), -, O (1) . . , , 200 000 .

+5
source

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


All Articles