Choosing a multiplier for a (string) hash function

后端 未结 3 2043
小鲜肉
小鲜肉 2021-02-05 14:03

Do you have any advice/rules on selecting a multiplier to use in a (multiplicative) hash function. The function is computing the hash value of a string.

3条回答
  •  生来不讨喜
    2021-02-05 14:47

    You want to use something that is relatively prime to the size of your set. That way, when you loop around, you won't end up on the same numbers you just tried.

提交回复
热议问题