Why is the size 127 (prime) better than 128 for a hash-table?

后端 未结 9 1295
深忆病人
深忆病人 2021-01-30 08:22

Supposing simple uniform hashing, that being, any given value is equally like to hash into any of the slots of the hash. Why is it better to use a table of size 127 and not 128?

9条回答
  •  鱼传尺愫
    2021-01-30 09:14

    If you have a perfect hash function that has an even distribution, then it doesn't matter.

提交回复
热议问题