我想知道为什么下面的代码片段是一个糟糕的哈希函数。
def computeHash(self, s): h = 0 for ch in s: h = h + ord(ch) # ord gives the ASCII value of character ch return h % HASH_TABLE_SIZE
如果我大幅增加哈希表的大小,这是否可以弥补哈希函数的不足?
python hash data-structures
data-structures ×1
hash ×1
python ×1