Answered step by step
Verified Expert Solution
Question
1 Approved Answer
* Please solve it with Java language! * In this homework, you must implement your own graph data structure by taking inspiration from your textbook
Please solve it with Java language!In this homework, you must implement your own graph data structure by taking inspiration from your textbook and use it to help to solve problem. You are not allowed to use any external library or jar file. Any solutions without using trie data structure are not evaluated! In this homework, you are expected to implement Trie data structure and following functions. Firstly, you should create a Trie data structure, and then you should insert all words read from the user. You can implement more than one Trie data structure. Finally, you should complete following functions: points Void Search String arg: This function should print true if given argument is in your Trie, otherwise it should print false. points Void countPrefix: This function takes all the strings in Trie and checks if a string is a prefix of other strings in Trie. It prints the number of occurrences for each string. For this function, you may use a symbol table that keeps track of the number of appearances of each key. Also, you should print prefix in alphabetical order of corresponding string. Note: You can change the parameter for this method if you need! points Void reverseFind String suffix: This function should print all strings end with given suffix in your Trie, lexicographically. For this function, you may consider using multitrie solution, or research and use more complex data structures such as suffix arrays. Also, you should print string in alphabetical order. points Void ShortestUniquePrefix Trie trie: This function should print shortest unique prefix to identify each string in your trie. If there is not any unique prefix, print not exists Note: You can change the parameter for this method if you need! points Void LongestCommonPrefix : This function should print longest common prefix for all strings in your trie. If there is not any unique prefix, print not exists Note: You can change the parameter for this method if you need! I will put the requiredsample output below: Sample Input :
Enter Operation Code:
call reverseFind
e
ate
curve
Enter Operation Code:
ned
borned
Enter Operation Code:
call ShortestUniquePrefix
at: not exists
ate: ate
ato: ato
borned: borne
born: not exists
curve: c
Enter Operation Code:
call LongestCommonPrefix
not exists
Enter Operation Code:
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