python 中的哈希表
我开始学习哈希表,所以有人可以解释该程序是如何工作的。不过,我应该在哪里写一个包含值的列表?
代码在这里: http://www.daniweb.com/software-development/python/threads/342511
I started learning hash tables, so could anybody explain how the programm works. Although, where should I write a list with values?
The code is here:
http://www.daniweb.com/software-development/python/threads/342511
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在看到的是带有链接的哈希表的实现。
这样做的目的是通过创建哈希值相同的值链来避免哈希冲突。
一般的实现是键包含一个指向链表的指针。当您想要插入一个值时,您可以将新元素添加到链表中,其中哈希值是该链表的键。
您可以在这里阅读更多相关信息:
http://en.wikipedia.org/wiki/Hash_table#Separate_chaining
What you are looking at is an implementation of Hash Tables with chaining.
The purpose of this is to avoid hash collisions by creating a chain of values in which their hash values are the same.
The general implementation is that the key contains a pointer to a linked list. When you want to insert a value, you add your new element to the linked list where the hash value is the key of that linked list.
You can read more about this here:
http://en.wikipedia.org/wiki/Hash_table#Separate_chaining