Question: Methods: public Store(int size) Create an array of Products and save the size of the hash table. java hashtable public int hashFun(String supplierAddress, int id)
Methods:
public Store(int size) Create an array of Products and save the size of the hash table.
java hashtable
public int hashFun(String supplierAddress, int id) Split the supplierAddress string, based on underscore.
Then, find the hash value according to the following steps: 1. Take the first character of the area, block, street, building and phone 2. Convert them to ASCII. 3. Cast them into int. 4. Add each value with power of 3 (3^0, 3^1,3^2, 3^3) accordingly. 5. Add the result to the product id. 6. Finally return (result) % table size to get the hash value. public boolean insert(Product p) Insert the product p in the proper location and return true. When a collision happens, use quadratic propping. If the hash table is full, return false. Note: duplication is not allowed.
public void printTable() Call toString() method and print the contents of the Hash Table in a readable way.
public int suppliers() Count and return number of suppliers that deal with the store.
public void maxPrices() print the product with the maximum price for each supplier.
public boolean deletProduct(String supplierAddress, int id) Search the hash function and delete product the has the given attributes (supplierAddress, id).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
