哈希 [英] hash
问题描述
获取一个值需要多长时间 - 在hash_map中键入?
谢谢
how much time does it take to lok for a value - key in a hash_map ?
Thanks
推荐答案
Douglas Dude写道:
Douglas Dude wrote:
需要多少时间才能获得一个值 - 在hash_map中输入密钥?< br $>
谢谢
how much time does it take to lok for a value - key in a hash_map ?
Thanks
我的意思是O符号。请帮助我因为我认为是O(1)。
这是正确的吗?
I mean the O-notation. Please help me because I think it is O(1). Is
this correct ?
Douglas Dude写道:
Douglas Dude wrote:
Douglas Dude写道:
Douglas Dude wrote:
>获取一个值需要多长时间 - 在hash_map中输入密钥?
谢谢
>how much time does it take to lok for a value - key in a hash_map ?
Thanks
我的意思是O符号。请帮助我因为我认为是O(1)。
这是对的吗?
I mean the O-notation. Please help me because I think it is O(1). Is
this correct ?
我没看到如何在_general
purpose_哈希表中查找O(1)运行时,是我假设的hash_map。
如果它使用链接,人们会期望使用N个项目和M个桶,
查找将平均和假设散列函数没有偏差,
取O(N / M),而不考虑生成散列的散列算法
,如果是这样的话需要进行操作。
-n
I don''t see how an O(1) runtime is possible for a lookup in a _general
purpose_ hash table, which is what I assume hash_map to be.
If it uses chaining, one would expect that with N items and M buckets,
lookups would, on average and assuming that the hash function is not biased,
take O(N/M), without taking into account the algorithm that generates the hash
out of the key, if such an operation is required.
-n
Douglas Dude写道:
Douglas Dude wrote:
Douglas Dude写道:
Douglas Dude wrote:
需要花多少时间才能获得一个值 - 在hash_map中输入密钥?< br $>
谢谢
how much time does it take to lok for a value - key in a hash_map ?
Thanks
我的意思是O符号。请帮助我因为我认为是O(1)。
这是对的吗?
I mean the O-notation. Please help me because I think it is O(1). Is
this correct ?
查询平均为O(1),罕见的最坏情况时间可能高达
0(n)。对于恒定的平均时间性能,使用设计良好的哈希函数是必要的,以产生均匀的元素分布并减少
哈希
Lookups are O(1) on average, the rare worst case time could be up to
0(n). For a constant average time performance the use of a
well-designed hash function is necessary to produce a uniform
distribution of elements and reduce the number of collisions within
the hash
这篇关于哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!