Question
JAVA DATA STRUCTURES Im creating a binary search tree class that takes two strings as parameters and then outputs data related to the parameters The
JAVA DATA STRUCTURES
Im creating a binary search tree class that takes two strings as parameters and then outputs data related to the parameters The point of the program is to take the common name of an animal, and then translate it to its genus scientific name.
example:
bst.translate("dog");
should output "Canis"
bst.translate("cat");
should output "Felis"
if no match is found in the binary search tree, then simply output the user input as is.
example:
bst.translate("hippo")l
should output "hippo" + a relevant message if no match is found.
1)
A method:
Public void insert(String commonName, String genusName) -The BST should use the common name to order the tree: a name should go to the left if it is alphabetically before the current nodes name and to the right if it is after this nodes name; duplicate names are ignored) -
2)
A method:
public void Translate(String commonName)
to get a translation: this method should take a String (commonName) and search for it recursively. If the name is not found, return null. if the commonName is found, return its genusName.
MOCK DATA:
commonName: GenusName:
dog canis
cat felis
horse equus
lion panthera
cat felis
we can assume all names are lowercase for the program.
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