Блог пользователя szawinis

Автор szawinis, история, 9 лет назад, По-английски

Picking the base and mod for string hashing is very important in decreasing the probability of hash collisions. How much are the guidelines affected by the problem itself? So far, I've read that the base should be larger than the alphabet, and the mod should be really large (but not overflow). But is there anything else?

  • Проголосовать: нравится
  • +14
  • Проголосовать: не нравится

»
9 лет назад, скрыть # |
 
Проголосовать: нравится +18 Проголосовать: не нравится

You sound like you are on the right track. The base and mod must be coprime — usually, you just choose a prime base and prime mod anyway. Furthermore, you usually need hash two or more mods to stay safe. This is because of the birthday paradox. Normally people use base 137 and hash in 1e9+7 and 1e9+9.