The essence of a chained hash table is that each key is located in exactly one slot, but the slot does not directly contain a value, rather it contains a list of values, all of which hash to that slot. To give you an idea, I'll write method contains which will look something like
def contains self,value):
h = self.hash(value)
for v in self.table[h]:
if v == value:
return True
return False
I am deliberately not using your code and not providing you directly with an answer to your question. Please stop and think, then write some of your own code. My code assumes the existence of class ChainingHashTable:... of which this is one method.
griswolf
Veteran Poster
1,176 posts since Apr 2010
Reputation Points: 344
Solved Threads: 262
Skill Endorsements: 1