Answered step by step
Verified Expert Solution
Link Copied!

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: (10 points) Void Search (String arg): This function should print true if given argument is in your Trie, otherwise it should print false. (20 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! (20 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 multi-trie solution, or research and use more complex data structures such as suffix arrays. Also, you should print string in alphabetical order. (25 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! (25 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 required/sample output below: Sample Input 1:
Enter Operation Code:
3// call reverseFind
e
ate
curve
Enter Operation Code:
3
ned
borned
Enter Operation Code:
4// call ShortestUniquePrefix
at: not exists
ate: ate
ato: ato
borned: borne
born: not exists
curve: c
Enter Operation Code:
5// call LongestCommonPrefix
not exists
Enter Operation Code:
6
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions