Question: python please Starting with your solution to the SimpleHashTableclass definition, define a class named QuadraticHashTable. The QuadraticHashtable contains the same methods defined in the SimpleHashTable
python please
Starting with your solution to the SimpleHashTableclass definition, define a class named QuadraticHashTable. The QuadraticHashtable contains the same methods defined in the SimpleHashTable class except the put() method. Add a method named get_new_hash_code_quadratic_probing (self, index, step) which takes two integers as parameters and uses the quadratic probing technique to determine where the key should be placed in the hash table when a collision occurs. Modify the put(self, key) method. The method should call the get_new_hash_code_quadratic_probing() method to calculate the next index position when a collision occurs. The method should raise an IndexError with the message "ERROR: The hash table is full." if the hash table is full when the put() method is called. For example, if the current hash table is [None, 1, 8, None, None, 15, None] and we would like to insert "22" into the hash table, you will get: index = 22 % 7 = 1 (collision) new_index = (1 + 1 * 1) % 7 = 2 (collision) new_index = (1 + 2 * 2) % 7 = 5 (collision) new_index = (1 + 3 * 3) % 7 = 3 Therefore, the next position is 3. Submit the entire class definition in the answer box. Keep a copy of your solution to this task because you will be extending it step by step in subsequent tasks. Note: you should copy your SimpleHashTable class implementation, change the class name to QuadraticHashtable, modify the put() method, and add a method called get_new_hash_code_quadratic_probing() to complete this task. For example: Test Result my_hash_table=QuadraticHashTable() [None, 1, None, None, None, None, None] my_hash_table.put(1) [None, 1, 8, None, None, None, None] print(my_hash_table) [None, 1, 8, None, None, 15, None] my_hash_table.put(8) [None, 1, 8, 22, None, 15, None] print(my_hash_table) my_hash_table.put(15) print(my_hash_table) my_hash_table.put(22) print(my_hash_table)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
