Question: Hey I need help with this question it is in python I dont understand how Im meant to search the the hashtable Consider the simpleHashtable

Hey I need help with this question it is in python I dont understand how Im meant to search the the hashtable Hey I need help with this question it is in python

Consider the simpleHashtable class definition in the answer box below. Add a method named search (self, search_key) to extend its functionality. The search method takes a search key as a parameter and searches for the key value in the hash table. This method should return a Tuple containing True (if the search key is found in the hash table) and the number of steps to find the value. The method should return False and the number of steps if the key is not found in the hash table. For example, if the hash table contains the following values: [None, 36, None, 24. None 12, None) and the search key is 3, the search() method should return false and the number of steps is 2 as the value at index 4 is None and therefore the function should not continue to search for the value. Submit the entire class definition in the answer box. Note: SimpleHashTable uses the linear probing technique to determine where the key should be placed in the hash table when a collision occurs. For example: Test Result hash_table = SimpleHashTable(7) [None, 36, None, 24, None, 12, None] values = [12, 24, 36] (True, 1) for value in values: (False, 1) hash_table.put(value) (False, 2) print(hash_table) print(hash_table.search(12)) print(hash_table.search(2)) print(hash_table search (3) Answer: (penalty regime: 0,0,5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) (self): Reset answer 1. class SimpleHashTable: 2 def _init_(self, size=7): self._size = size self._slots = [None] * size def str return str(self._slots) def get_hash_ code(self, key): return key % self._size 9 def put(self, key): 10 self.get_hash_code(key) 11 slots[index] -- None: #empty self._slots[index] = key else: new_index = self.get_new_hash_code_linear_probing(index) while self._slots[new_index] != None: #look for an empty slot new_index = self.get_new_hash_code_linear_probing (new_index) self._slots[new_index] =key 18 def get_new_hash_code_linear_probing (self, index): return ( index + 1 ) % self._size 20 index if self. 12 13 14 15 16 17 19

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!