Question: I am currently learning about Hash Tables in Java. For this particular lab, I need to use a .dat file for my input, the data
I am currently learning about Hash Tables in Java. For this particular lab, I need to use a .dat file for my input, the data that is supposed to be in it is the sample data in the photo. Also will definitely leave an upvote!

Number:
public class Number { private int theValue; public Number(int value) { } public int getValue() { return theValue; } public boolean equals(Object obj) { return false; } public int hashCode() { return 0; } public String toString() { return ""; } }NumberTester:
public class NumberTester { public static void main(String[] args) { Number one = new Number(45); System.out.println(one.hashCode()); Number two = new Number(107); System.out.println(two.hashCode()); Number three = new Number(213); System.out.println(three.hashCode()); } }HashTable:
import java.util.LinkedList; import java.util.Scanner; import static java.lang.System.*; public class HashTable { private LinkedList[] table; public HashTable( ) { table = new LinkedList[10]; } public void add(Object obj) { System.out.println("add"); int i = obj.hashCode(); } public String toString() { String output="HASHTABLE "; return output; } }HashTableRunner:
import java.util.LinkedList; import java.util.Scanner; import java.io.File; import static java.lang.System.*; public class HashTableRunner { public static void main ( String[] args ) { try{ //make a new table //read from the file //load stuff into the table //print out the table } catch(Exception e) { System.out.println("Houston, we have a problem!"); } } }A+ Computer Science HASHTABLE OF INTS Lab Goal: The lab was designed to teach you more about hash tables. Lab Description : Write a hash table program. A hash table can be implemented using an array of linked lists. Use an array of Java LinkedLists. Use int values to construct Number objects. Organize the Number objects in the proper bucket using the hashCode of each Number. The hash formula for Number consists of taking the value and moding(%) it by 10(which in most cases will be the size of the table). There are no duplicates in this hash table. Sample Data : Files Needed :: Number.java NumberTester.java HashTable.java HashTableRunner.java numbers.dat 30 34 56 78 09 12 23 43 45 78 98 76 65 54 43 21 1 2 3 4 5 6 7 8 9 11 10 1 2 3 4 EXTENSION : Rewrite the Hash Table class using an array of ListNode instead of an array of LinkedList. 1/change the instance variable declaration private ListNode[] table; Sample Output: HASHTABLE bucket 0 10 bucket 1 21 1 11 bucket 2 12 2 bucket 3 23 43 3 bucket 4 34 54 4 bucket 5 45 65 5 bucket 6 56 76 6 bucket 77 A+ Computer Science - HashTables - www.apluscompsci.com bucket 8 78 98 8 bucket 99
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
