Question 2: Hash Table Implementations of a Dictionary Read through all of the i
ID: 3912388 • Letter: Q
Question
Question 2: Hash Table Implementations of a Dictionary Read through all of the instructions for question 2 before beginning, and refer back to these instructions frequently to ensure you have completed all required details. In this question you will create two new implementations of a dictionary, to be used with the Scrabble word generator from Assignment 2. Both dictionary implementations will use a hash table to store the contents of the dictionary as described below The first implementation will use open addressing, with double hashing to resolve collisons. The second implemen- tation will use separate chaining. Details specific to each hash table are listed in separate sections below A modified version of the main class from Assignment 2 is provided. The provided file A4Q2ProvidedCode.java contains code that will generate combinations of letters, calculate the points for each word, and determine a best word. It performs the search for the best word twice, once with each type of dictionary, and outputs the result of each search. Do not make any modifications to the provided code. You will only write the Dictionary classes and any supporting classes they require) that will be used by the main method The provided code uses the words alpha.txt file from assignment 2 (obtained from https://github.com/dwy1/english-vords). Place a copy of this file in your working directory Begin by reviewing the provided code, noting how the dictionary classes are called in the main and supporting methods In order to be compatible with the provided code, your dictionary clsses must be named DictionaryOpen and DictionaryChain. Each dictionary class must have the following methods, which can be called from outside the dictionary class. Use additional (Drivate) helner methods as aDroDriate.Explanation / Answer
Dear Student,
Although we are going to implement a Dictionary. So the basic data structure will be a key-value pair. This means you have to use Map<K,V> in storing the dictionary. The best implemention of Map<K,V> is HashMap<K,V>. Both are available in java.util package.
Even though we are using HashMap, we have to create our own hashing algorithm to hash the keys OR you have to store the keys only in a predefined case(UPPER CASE/LOWER CASE).
i.e. Apple -->APPLE
apple --> APPLE
aPPle--> APPLE
This will avoid key search case sensititvity. The impementation will be like as below.
Hope this helps.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.