Hash Table implementation in Python

Pubblicato il: 17 ottobre 2022
sul canale di: 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...


In questa pagina del sito puoi guardare il video online Hash Table implementation in Python della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Python Developer 17 ottobre 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 5 volte e gli è piaciuto 0 spettatori. Buona visione!