Question
We wish to build a Hash Table, which is able to deal with collision by using linear and quadratic probing. Please write a public class
We wish to build a Hash Table, which is able to deal with collision by using linear and quadratic probing. Please write a public class HashLinQuad as follows: public class HashLinQuad { private int[] table; //hash table private int size; //current number of elements private int capacity //capacity of the hash table private HashLinQuad (int size){ table = new int[size]; } public int addLin (int obj) { ... //add obj into table using linear probing } public int addQuad (int obj){ ... //add obj into table using quadratic probing } ... } 1. Implement the two methods addLin and addQuad that apply linear and quadratic probing, respectively. 2. Test your implemented methods addLin and addQuad . To this end, create the following two objects in class Main : HashLinQuad linHashTable = new HashLinQuad(1249);
HashLinQuad quadHashTable = new HashLinQuad(1249); 3. Please insert the same 1000 random integer values (in the same order) into:
a. the object `linHashTable` by using the method `addLin` and count the number of collisions. b. the object `quadHashTable` by using the method `addQuad` and count the number of collisions.
4. According to the results, compare and discuss both collision resolution strategies as a comment in your implementation (e.g., directly below the lines above).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started