Reason for 5381 number in DJB hash function?

后端 未结 3 1285
盖世英雄少女心
盖世英雄少女心 2020-12-04 08:03

Can anyone tell me why the number 5381 is used in DJB hash function ?

DJB Hash function is

h(0) = 5381

h(i) = 33 * h(i-1) ^ str[i]

A c progra

3条回答
  •  醉话见心
    2020-12-04 08:23

    5381 is just a number that, in testing, resulted in fewer collisions and better avalanching. You'll find "magic constants" in just about every hash algo.

提交回复
热议问题