Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me finish this assignment in Java using the two Hashing functions below the picture. Below is the code for HashMap and HashEntry public

Please help me finish this assignment in Java using the two Hashing functions below the picture. image text in transcribed
Below is the code for HashMap and HashEntry
public class HashMap {
private final static int TABLE_SIZE = 100;
HashEntry[] table;
HashMap() {
//Implement
}
public String get(int key) {
// Implement
}
public void put(int key, String value) {
// Implement
}
public void linearProbe(int key, String value){
// Implement
}
public void quadraticProbe(int key, String value){
// Implement
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
public class HashEntry {
private int key;
private String value;
HashEntry(int key, String value) {
this.key = key;
this.value = value;
}
public int getKey() {
return key;
}
public String getValue() {
return value;
}
public void setValue(String val) {
this.value = val;
}
}
2. Create a hash table that is made of elements HashElement(int Key, String Value). The size of hash table will be 100. 3. Implement the following methods for the hash table: a. put(int Key, String Value): i. Puts the key value pair in the hash table at a certain index. ii. You need to implement a simple hash function H(key) key mod mapsize to find the index where you will put the pair iii. If collision occurs, i.e., a pair already exists in that index and the key is not the same as the current key, then you will use this function to resolve the collision, H(key) (7 H(key+1) mod mapsize, until you get an empty slot. iv. If the index is already full and the keys are the same, just replace the old value with the new one. b. get int Key): i. Gets the value associated with the Key. ii. You should not do linear search throughout the hash table for the key, rather you will calculate the index using the hash function stated above, go directly to that and retrieve the value. 4. Write a driver program to test your implementation of hash table. Allow the user to put or get data

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

1.who the father of Ayurveda? 2. Who the father of taxonomy?

Answered: 1 week ago

Question

Commen Name with scientific name Tiger - Wolf- Lion- Cat- Dog-

Answered: 1 week ago

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago