Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Download the file lab10_base.zip, and extract as a starting point. The code includes a driver class (HashtableDriver), and a class for the hash table itself

image text in transcribed

image text in transcribed

image text in transcribed

Download the file lab10_base.zip, and extract as a starting point. The code includes a driver class (HashtableDriver), and a class for the hash table itself (Hashtable). There is an empty function in the Hashtable class, called insert), that needs to be implemented. Furthermore, there are two subclasses LinearHashtable and QuadraticHashtable, which need to be implemented to provide the definition of the rehash) method The rehash () method is used when determining the hash table index. When the initial index, returned by the provided hash) method, represents a space in the array list that is already occupied, a probing strategy is used. The rehash() method takes the previously found index (which represents an occupied space in the array list), and uses it to determine the next index. rehash() will implement these strategies: 1. LinearHashtable - the rehash() method will simply add one to the previous index, returning the new value modulus the size of the array list (capacity) o This is called linear probing en.wikipedia.or dia.org/wiki/Linear probin 2. QuadraticHashtable - the rehash() method will square the previous index, returning the new value modulus the size of the array list (capacity) o This is a variation of a probing strategy called quadratic probing ia ua ati in The insert() method will continuously call rehash() until an unoccupied position has been found, then it will insert to the new value at that position. While performing the probing, use the instance variable probeCount to keep track of how many probes is required for both hash tables import java.util.*; public abstract class Hashtable T> protected int capacity 0; private Liststring keys null; private List values null; private int probeCount ; public int getProbeCount O return this.probeCount; public void resetProbeCount) this probeCount -0; public Hashtable(int capacity) this.keys = new ArrayListstring>(); for (int i-0; i (); line arTable = new QuadraticHashtablecString> guadraticTable LinearHash table (size); = new QuadraticHashtableo, rsize) // generate random strings and insert them into both tables for (int i-0 i protected int capacity 0; private Liststring keys null; private List values null; private int probeCount ; public int getProbeCount O return this.probeCount; public void resetProbeCount) this probeCount -0; public Hashtable(int capacity) this.keys = new ArrayListstring>(); for (int i-0; i (); line arTable = new QuadraticHashtablecString> guadraticTable LinearHash table (size); = new QuadraticHashtableo, rsize) // generate random strings and insert them into both tables for (int i-0 i

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

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

What are the main objectives of Inventory ?

Answered: 1 week ago

Question

Explain the various inventory management techniques in detail.

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