Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello , i need help with this java program Step 1: Hash Code Generation. Create a map element class for pairs. This will be a

Hello , i need help with this java program

image text in transcribed

Step 1: Hash Code Generation. Create a map element class for pairs. This will be a non-generic implementation. Specifically, have Keys of Integer type, while Values can be anything you want. Ensure your implementation has the following two methods (in addition to standard methods you will need Write a constructor that generates a new pair with a random Integer key Write a method: public int hashCode (). This should implement one of the hashing methods discussed in class (e.g. polynomial accumulation, cyclic shifts, etc.). The output of hashCode () is int; your hash does not have to use the full capacity of int but should be at least 16 bits. Step 2: Compression and Hash Tables. Create an abstract hash table with a fixed capacity (passed in as an int at construction time). Create a set of children classes that are concrete hash tables that implement the following collision resolution mechanisms: (1) separate chaining (the bucket object can be any suitable data structure), (2) linear probing and (3) quadratic probing. Any function that is the same across these three implementations should be placed in the abstract parent class. To compress the output of hashCode () to an index in the table, mod the output by the capacity of the table. The following methods should be supported: size(): Returns the number of entries in M. isEmpty): Returns a boolean indicating whether M is empty get(): Returns the value vassociated with key k, if such an entry exists otherwise returns null. put(k, v): If M does not have an entry with key equal to k, then adds entry (k, v) to M and returns null; else, replaces with v the existing value of the entry with key equal to k and returns the old value remove(&): Removes from M the entry with key equal to k, and returns its value; if M has no such entry, then returns null. Step 1: Hash Code Generation. Create a map element class for pairs. This will be a non-generic implementation. Specifically, have Keys of Integer type, while Values can be anything you want. Ensure your implementation has the following two methods (in addition to standard methods you will need Write a constructor that generates a new pair with a random Integer key Write a method: public int hashCode (). This should implement one of the hashing methods discussed in class (e.g. polynomial accumulation, cyclic shifts, etc.). The output of hashCode () is int; your hash does not have to use the full capacity of int but should be at least 16 bits. Step 2: Compression and Hash Tables. Create an abstract hash table with a fixed capacity (passed in as an int at construction time). Create a set of children classes that are concrete hash tables that implement the following collision resolution mechanisms: (1) separate chaining (the bucket object can be any suitable data structure), (2) linear probing and (3) quadratic probing. Any function that is the same across these three implementations should be placed in the abstract parent class. To compress the output of hashCode () to an index in the table, mod the output by the capacity of the table. The following methods should be supported: size(): Returns the number of entries in M. isEmpty): Returns a boolean indicating whether M is empty get(): Returns the value vassociated with key k, if such an entry exists otherwise returns null. put(k, v): If M does not have an entry with key equal to k, then adds entry (k, v) to M and returns null; else, replaces with v the existing value of the entry with key equal to k and returns the old value remove(&): Removes from M the entry with key equal to k, and returns its value; if M has no such entry, then returns null

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

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

Understand and explain cultural discourses

Answered: 1 week ago