使用Btree来存储字典数据?
我在使用 btree 在字典中存储 100.000 个单词的数据时遇到问题(一个单词包括头和定义),我不知道如何使用哈希函数将 100.000 个单词哈希为 100.000 个不同的键,我的老师给出了一些提示只是哈希 3 个单词的第一个字符,但我无法想象某些单词超过 3 个字符会怎样。请帮助我T_T
I have a problem using btree to store data of 100.000 words in a dictionary ( a word include a head and definition), i don't know how to hash 100.000 words to 100.000 different key with a hash function , my teacher give some hint that just hash 3 first character of word but i can't image what would do with some word have more than 3 character. please help me T_T
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里的想法可能是散列冲突很好:您计算一个散列(例如,通过添加前三个字符的 ASCCI 值;但这在现实世界中几乎不符合“散列”的资格)并比较散列。如果它们相等,则进行(更昂贵的)字符串比较。喜欢:
The idea here is probably that hash-collisions are fine: you calculate a hash (for example by adding the ASCCI values of the first three characters; but that hardly qualifies as "hash" in the real world) and compare the hashes. If they are equal, you do a (more expensive) string comparison. Like: