确定给定 key 的双重哈希函数 ->哈希位置值

发布于 2024-12-17 11:31:21 字数 161 浏览 1 评论 0原文

给定一堆键及其散列值,如何确定双重散列函数?

更新

我认为 h(x) = k % 13 + 1

Given a bunch of keys and their hashed values, how can I determine the double hash function?

UPDATE

I think h(x) = k % 13 + 1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

累赘 2024-12-24 11:31:21
h(x) = (x+1) % 13

你有什么,但你想要在加一后取模,这样结果值的范围是 [0,12] 而不是 [1,13] ...但你做对了。

我对 r(x) 能想到的最好的办法是:

r(x) = (x+6) % 19

这对我来说真的毫无意义,为什么会这样,但我得出这个结论的方法是,模除数必须将移位增加 6,因为给出的值(38 和 101 的模 13 相差 1,并且它们相距 6 个空格)。我觉得模 19 确实实现了这一突破,所以虽然这似乎很合适,但我会寻求更好的答案,但这就是我想到的,我觉得我有一种超越猜测和检查的方法。

祝你好运,如果您对此有任何疑问,请随时发表评论。

h(x) = (x+1) % 13

what you had, but you want the modulo after adding one so the resultant values are range [0,12] not [1,13] ... but you had it right.

the best I could come up with for r(x) was:

r(x) = (x+6) % 19

this really makes no sense to me why it would be this, but the way that I came to this was that the modulo divisor must have increased the shift by 6 because of the values given (38 and 101 have a difference of 1 for modulo 13 and they were six spaces apart). I feel like the modulo 19 really makes this break, so while this seems to fit, I would seek a better answer, but that's what I came up with and I feel like I kind of had a method over guess and check.

Best of luck, feel free to drop comments if you have any questions about this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文