Question
Can I get the following answer please I am not understanding also can I have the following in JAVA CODE, please. Problem: Build a hash
Can I get the following answer please I am not understanding also can I have the following in JAVA CODE, please.
Problem: Build a hash table for websites
General Setup and Requirements:
- A website w consists of two fields: (url, name)
- Use ws url to compute ws hash key:
- Hash code: url -> integer
- Compression function: integer -> [0, m-1] where m is the size of the table
- In your hash table implementation, it should have at least three methods:
- put(key k, value v): Put a new website by its key k to the hash table
- get(key k): Return the website associated with k
- delete(key k): Remove the website associated with k
- As a test suite, the following operations should be performed:
- Put (www.uscupstate.edu, USC Upstate)
- Put (www.google.com, Google)
- Put (www.yahoo.com, Yahoo)
- Get www.google.com
- Delete www.yahoo.com
- Get www.uscupstate.edu
- Get www.google.com
- Get www.yahoo.com
Part a. Implement a hash table to store websites using linear probing to handle collision. Sample code LinearProbingHashTable.java is attached for your reference. It implements the hash table using linear probing. Attach your code and screenshots.
Part b. Implement a hash table to store websites using double hashing to handle collision. You can modify the Sample code in Part a for this part. Attach your code and screenshots.
Linear probing: This technique is used when we have more index in the table then the values to be stored. Linear probing technique work on the concept of keep incrementing until you find the empty slot. The pseudo code looks like this.
index = h(k)
while( val(index) is occupied)
index = (index+1) mod m
Double hashing technique: In this technique, we use two hashing functions h1(k) and h2(k). If the slot at h1(k) is occupied then the second hashing function h2(k) used to increment the index. The pseudo-code looks like this.
index = h1(k)
while( val(index) is occupied)
index = (index + h2(k)) mod m
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started