Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Programming, Data Design, and Data Structures We are hired to implement an

ID: 3748950 • Letter: J

Question

Java Programming, Data Design, and Data Structures

We are hired to implement an interactive dictionary. Our dictionary takes input from users and uses the input as search key to look up values associated with the key. Requirements: - Coding: No hard coding, https://en.wikipedia.org/wiki/Hard_coding .

- Data Source: Store the original data in a set of enum objects. Each keyword, each part of speech, and each definition must be stored in a separate data field. Do not combine them such as storing three parts in one String.

- Data Structure: Use existing data structure(s) or creating new data structure(s) to store our dictionary’s data.

- Data Loading: When our program starts, it loads all the original data from the enum objects into our dictionary’s data structure.

- User Interface: A program interface allows users to input search keys and displays returned results. Our program searches the dictionary’s data (not the enum objects) for values associated with the search keys.

- Identical Output: Our program’s output must be identical to the complete sample run’s output.

1. Program Analysis to Program Design, 10 points In 1 full page, please explain the following in detail:

Your analysis of the provided information and the provided sample output.

What problem you are solving. How you store data in enum objects. And why.

Which data structure(s) you use/create for your dictionary. And why.

2. Program Implementation, 35 points

Does your program work properly?

How will you improve your program?

Sample run:

Search: csc220 ! Loading data... !Loading completed... CSC220 [adjectivel: Ready to create complex data structures CSC220 [noun] Data Structures CSC220 [verb] : To create dta 5t ructure -DICTIONARY 340 JAVA-- Search: csc340 Search: pLacehoLder CSC340 adjectivelC++ version of CsC210 CSC220 + more C5C340 [noun]A CS upper division course CSC340 [noun] Many hours outside of class CSC340 [nounProgramming Methodology Placeholder [adjective To be updated... Placeholder [adjective To be updated... Placeholder [adverbTo be updated. .. Placeholder [conjunction] To be updated Placeholder [interjection To be updated Placeholder [noun] : be updated Placeholder [noun] To be updated... Placeholder [noun] : To be updated Placeholder [preposition] To be updated... Placeholder [pronoun To be updated... Placeholder [verb] To be updated... Search: csc340 noun distinct CSC340 [noun]: A CS upper division course CSC340 [noun] Many hours outside of clas3 CSC340 [noun] : Programming Methodology Search: Facebook Search: pLACEholder distinct Search: verh Placeholder [adjective] To be updated Placeholder [adverbTo be updated. .. Placeholder [conjunction] To be updated... Placeholder [interjection] To be updated... Placeholder [noun] : be updated Placeholder [preposition] Io be updated.. . Placeholder [pronoun To be updated... Placeholder [verb]To be updated... Verb [noun] Verb is a word or group of words that expres363 Search: verb verb Search verb noun Search: pLaCEholder noun Verb [noun] : Verb is a word or group of words that expresses Search g Placeholder [noun] To be updated Placeholder [noun] To be updated... Placeholder [noun] : To be updated THANK YOU Search: placeholder noun distinct Placeholder [noun] To be updated... Search: placeholder adjective Placeholder [adjective To be updated.. Placeholder [adjectivel: To be updated.. Search: placeholder oops 2nd argument must be a part of speech or "distinct"> Search: csc210 CSC210 [adjectivel :Comfortable with Objects and Classes CSC210 [adjectivel Ready for CSC 220 CSC210 [noun]Intro to Java CSC210 [verb] : learn Java

Explanation / Answer

//Dictionary implemented using a Trie Tree.

public class Dictionary {

private HashMap<Character,Node> roots = new HashMap<Character,Node>();

/**

* Search through the dictionary for a word.

* @param string The word to search for.

* @return Whether or not the word exists in the dictionary.

*/

public boolean search(String string) {

if (roots.containsKey(string.charAt(0))) {

if (string.length()==1) {

return true;

}

return searchFor(string.substring(1),roots.get(string.charAt(0)));

} else {

return false;

}

}

/**

* Insert a word into the dictionary.

* @param string The word to insert.

*/

public void insert(String string) {

if (!roots.containsKey(string.charAt(0))) {

roots.put(string.charAt(0), new Node());

}

insertWord(string.substring(1),roots.get(string.charAt(0)));

}

//Adds a new word to the trie tree.

private void insertWord(String string, Node node) {

final Node nextChild;

if (node.children.containsKey(string.charAt(0))) {

nextChild = node.children.get(string.charAt(0));

} else {

nextChild = new Node();

node.children.put(string.charAt(0), nextChild);

}

if (string.length() == 1) {

nextChild.endOfWord = true;

return;

} else {

insertWord(string.substring(1),nextChild);

}

}

//Recursive method that searches through the Trie Tree to find the value.

private boolean searchFor(String string, Node node) {

if (string.length()==0) {

if (node.endOfWord) {

return true;

} else {

return false;

}

}

if (node.children.containsKey(string.charAt(0))) {

return searchFor(string.substring(1),node.children.get(string.charAt(0)));

} else {

return false;

}

}

}

Node.java

publicclass Node {

public Node parent;

public Boolean endOfWord = false; //Does this Node mark the end of a particular word?

public HashMap<Character,Node> children = new HashMap<Character,Node>();

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote