Hash Table implementation in Python

Published: 17 October 2022
on channel: Python Developer
5
0

class HashTable:
def __init__(self):
self.MAX = 10
self.arr = [None for i in range(self.MAX)]

def get_hash(self,key):
hash = 0
for char in key:
hash += ord(char)
return hash % self.MAX

def __getitem__(self, index):
h = self.get_hash(index)
return self.arr[h]

def __setitem__(self, key, value):
h = self.get_hash(key)
self.arr[h] = value
JamBoard
https://jamboard.google.com/d/14zl1_v...

GIST Link
https://gist.github.com/divey-learnin...


On this page of the site you can watch the video online Hash Table implementation in Python with a duration of hours minute second in good quality, which was uploaded by the user Python Developer 17 October 2022, share the link with friends and acquaintances, this video has already been watched 5 times on youtube and it was liked by 0 viewers. Enjoy your viewing!