Question: Hash Table ADT with chaining implementation: How do I update the the following Python code to use open addressing with linear probing? Yes, Python. What
Hash Table ADT with chaining implementation: How do I update the the following Python code to use open addressing with linear probing?

Yes, Python. What extra information do you need?
# HashTable ADT with chaining implementation # This hashtable accepts only strings and hashes based on their # ASCII value of the first char # The constructor takes in the size of the table class MyHashtable (object): def init (self, size): # Creates an empty hashtable self.size = size # Create the list (of size) of empty lists (chaining) self. table = [] for i in range (self.size): self.table.append([]) def str (self): # for print return str(self.table) def insert (self, elem): # Adds an element into the hashtable hash = ord(elem[0]) % self.size self.table[hash].append(elem) def member (self, elem) : # Returns if element exists in hashtable hash = ord (elem[0]) % self.size return elem in self.table[hash] def delete (self, elem): # Removes an element from the hashtable hash = ord (elem[0]) % self.size self.table[hash].remove (elem) # Testing code MyHashtable (10) s.insert ("amy") #97 s.insert("chase") #99 s.insert("chris") #99 print (s.member ("amy")) print (s.member("chris")) print (s.member ("alyssa")) s.delete ("chase") print (s.member ("chris")) # You can use print (s) at any time to see the contents # of the table for debugging #print(s) S = # HashTable ADT with chaining implementation # This hashtable accepts only strings and hashes based on their # ASCII value of the first char # The constructor takes in the size of the table class MyHashtable (object): def init (self, size): # Creates an empty hashtable self.size = size # Create the list (of size) of empty lists (chaining) self. table = [] for i in range (self.size): self.table.append([]) def str (self): # for print return str(self.table) def insert (self, elem): # Adds an element into the hashtable hash = ord(elem[0]) % self.size self.table[hash].append(elem) def member (self, elem) : # Returns if element exists in hashtable hash = ord (elem[0]) % self.size return elem in self.table[hash] def delete (self, elem): # Removes an element from the hashtable hash = ord (elem[0]) % self.size self.table[hash].remove (elem) # Testing code MyHashtable (10) s.insert ("amy") #97 s.insert("chase") #99 s.insert("chris") #99 print (s.member ("amy")) print (s.member("chris")) print (s.member ("alyssa")) s.delete ("chase") print (s.member ("chris")) # You can use print (s) at any time to see the contents # of the table for debugging #print(s) S =
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
