Hash Table implementation in Python

Publicado em: 17 Outubro 2022
no canal de: 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...


Nesta página do site você pode assistir ao vídeo on-line Hash Table implementation in Python duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Python Developer 17 Outubro 2022, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 5 vezes e gostou 0 espectadores. Boa visualização!