The aim here is to develop a code in Java for implementing the multiplication method for a hash table.
Perform the following steps:
- Implement a class with a method which accepts an integer and returns a hash value using the multiplication method shown in this section. The constant k is passed in as the class constructor. The method signature should be:
int hashKey(int key, int tableSize)
- The following code shows an implementation for the multiplication hash function:
private double k;public MultiplicationHashing(double k) { this.k = k;}public int hashKey(Integer key, int tableSize) { return (int) (tableSize * (k * key % 1));}