Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task: Implementation of the ProbeHashTable class with linear probing. The template of ProbeHashTable class and relevant classes are given below you must use the same

Task: Implementation of the ProbeHashTable class with linear probing.

The template of ProbeHashTable class and relevant classes are given below you must use the same method headers:

public class ProbeHashTable extends AbstractHashMap { private MapEntry[] table; private MapEntry DEFUNCT = new MapEntry(null,null); private int count = 0; //constructors private boolean compareStr(String s, String t) { count++; return s.equals(t); } protected void createTable() { // your implementation here } private boolean isAvailable(int i) { // your implementation here } private int findSlot(int h, String k) { // your implementation here } protected Object bucketPut(int h, Object key, Object value) { // your implementation here } protected Object bucketGet(int h, Object key) { // your implementation here } protected Object bucketRemove(int h, Object key) { // your implementation here } private class KeyIterable implements Iterable { public Iterator iterator() { ArrayList buffer = new ArrayList(n); for (int i=0; i
public abstract class AbstractMap { public abstract Object get(Object key); public abstract Object put(Object key, Object value); public abstract Object remove(Object key); public abstract boolean isEmpty(); public abstract int size(); public abstract Iterable keySet(); } 

Grading Criteria:

(40%) ProbeHashMap.java: Implement the ProbeHashMap class as we discussed in the lectures. Your implementation has to follow the specification given. Any other implementation (there are tons of HashTable code on the Internet) will not receive any credit.

(20%) All other supporting classes given in the lecture, including AbstractHashMap.java, AbstractMap.java, MapEntry.java, ArrayList.java, List.java, OutOfRangeException.java, and SArrayIterator.java.

(30%) Test.java: write a test program to create a hash table with the default size (61). Inport 28 data items (given by a text file). The data file "roster.txt" is provided, which contains the offense players of Cleveland Browns. Please use the first column, the last name, as the key, and treat the rest of information as value. Please perform the following tasks after the data are imported to the hash table:

Print out the table in the format of tuples;

Obtain an iterable instance of key set and then print it out;

Print out the number of collisions occurred during the data insertion.

The roster.txt file looks like this:

image text in transcribed

Mayfield Stanton QB 6' 1" 215 lbs R 6' 3" 226 lbs 12 6' 1"217 lbs 8 5' 11" 227 lbs R Michigan State Virginia Tech 9 3 Hilliard Johnson Jr. Callaway Higgins WR 5' 11" 202 lbs R 5' 11" 200 lbs R Florida 6' 1"198 lbs 3 5' 11" 196 lbs 5 6' 2"215 lbs 3 Colorado State 6' 2"200 lbs R Texas A&M Mari Scott Streater Willies WR 0 Fresno State 2 5 1 6' 4" 207 lbs R 6' 5" 246 lbs 1 6' 3" 257 lbs 3 6' 3" 245 lbs 3 6' 7"270 lbs 5 6' 4" 246 lbs 2 Texas Tech Oregon Charles TE DeValve TE Princeton Tretter c Bitonio Corbett G Watford G Zeitler G Harrison Robinson 6' 4" 307 lbs 6 6' 4" 305 lbs 5 6' 4"306 lbs R 6' 3" 300 lbs 6 6' 4" 315 lbs 7 Corne11 Nevada Nevada James Madison Wisconsin 5 West Georgia Auburn 6' 5"330 lbs 5 Mayfield Stanton QB 6' 1" 215 lbs R 6' 3" 226 lbs 12 6' 1"217 lbs 8 5' 11" 227 lbs R Michigan State Virginia Tech 9 3 Hilliard Johnson Jr. Callaway Higgins WR 5' 11" 202 lbs R 5' 11" 200 lbs R Florida 6' 1"198 lbs 3 5' 11" 196 lbs 5 6' 2"215 lbs 3 Colorado State 6' 2"200 lbs R Texas A&M Mari Scott Streater Willies WR 0 Fresno State 2 5 1 6' 4" 207 lbs R 6' 5" 246 lbs 1 6' 3" 257 lbs 3 6' 3" 245 lbs 3 6' 7"270 lbs 5 6' 4" 246 lbs 2 Texas Tech Oregon Charles TE DeValve TE Princeton Tretter c Bitonio Corbett G Watford G Zeitler G Harrison Robinson 6' 4" 307 lbs 6 6' 4" 305 lbs 5 6' 4"306 lbs R 6' 3" 300 lbs 6 6' 4" 315 lbs 7 Corne11 Nevada Nevada James Madison Wisconsin 5 West Georgia Auburn 6' 5"330 lbs 5

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

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions