Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use Open or Closed Hashing to store the following information in a hash table of

ID: 3824971 • Letter: U

Question

Use Open or Closed Hashing to store the following information in a hash table of your own size. The items are expected to consist of about 20 string values as the keys, with integers as the associated data. Implement a conversion into int from the key string value then store the value into the hash table (open or closed, your choice). Explain what you did and why you did it in an associated report. Attach your code to the report and submit as a word file. Test your code with the following actions as inputs (program these in main)

1. create new hash table

2. input key, value {John, 1001}

3. input key value {Bob, 999}

4. input key value {Sue, 2012}

5. input key value {Mary, 101}

6. retrieve all inputs (one by one), outputting the key and value to standard output

Use Open or Closed Hashing to store the following information in a hash table of your own size. The items are expected to consist of about 20 string values as the keys, with integers as the associated data Implement a conversion into int from the key string value then state the value into the hash table (open or closed, your choice). Explain what you did and why you did it in an associated report. Attach your code to the report and submit as a Word file. Test your code with the tollowing actions as inputs (program these in main) 1. create new hash table 2. input key, value John, 1001) 3, input key value Bob, 999) 4. input key value (Sue, 2012) 5. input key value (Mary 101) 6., retrieve all inputs (one by one), outputting the key and value to standard output

Explanation / Answer

The below code will create a hash table and with the required functionalities which are discussed in the question and also comments are added for better understanding.

package Chegg;

import java.util.Hashtable;
import java.util.Enumeration;

public class HashtableChegg {

public static void main(String[] args) {

Enumeration names;
String key;

// Creating a Hashtable
Hashtable<String, Integer> hashtable =
new Hashtable<String, Integer>();

// Addition of Key , Value pairs into Hashtable
hashtable.put("John",1001);
hashtable.put("Bob",999);
hashtable.put("Sue",2012);
hashtable.put("Mary",101);
  
names = hashtable.keys();
while(names.hasMoreElements()) {
key = Integer.parseInt(names.nextElement());        //conversion into int from the key string value
System.out.println("Key: " +key+ " & Value: " + hashtable.get(key)); //outputting the key and value to standard output
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote