JAVA In this assignment, you will implement your own Dictionary-type data struct
ID: 3592820 • Letter: J
Question
JAVA In this assignment, you will implement your own Dictionary-type data structure that stores a key/value pair in an array or vector. The backing array or vector must be strongly typed (use a generic or a template class). The key must be a string and the value stored may be any object type. In addition to the constructor, the data structure must utilize the methods shown below to store (set) and retrieve (get) data from the data structure. Hashing must be utilized to convert the key into an index for use in the array. Your design must provide a discussion on the hashing algorithm that will be utilized. A discussion must also be present on how collisions will be handled. The data structure will be used within a program that addresses the scenario defined below. Note that you may implement your data structure to address the solution below.
public void set(string key, T value)
public T get(string key)
Explanation / Answer
I created a data structure shown below
To store Words, I am thinking to use TreeSet
because
TreeSet provides an implementation of the Set interface that uses a tree for storage. Objects are stored in sorted, ascending order. Access and retrieval times are quite fast, which makes TreeSet an excellent choice when storing large amounts of sorted information that must be found quickly.
Or I can use HashMap, where the hashcode of word and synonyms word instance made equal which could enable faster retrieval.
Still I could see lot of challenges
When ever new word is added how to link with its synonyms
Look up would be slow when there are huge number of words
Editing word also should reflect synonyms and vice versa
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.