Question: Submit the zipped Eclipse program including at least Project4.java, BinarySearchTree.java, and States4.csv. Implement a binary search tree class. The binary search tree will be created

Submit the zipped Eclipse program including at least Project4.java, BinarySearchTree.java, and States4.csv.

Implement a binary search tree class. The binary search tree will be created from the same state data that was used in the last project. Use the following class definition for a node in the tree (put this inside your search tree class and do not change it, except to add comments):

private class Node {

String stateName;

int statePopulation;

Node leftChild;

Node rightChild;

public Node(String state, int population) {

stateName = state;

statePopulation = population;

} public void printNode() {

System.out.printf("%-25s%,10d ", stateName, statePopulation);

} }

(1) . Create the BinarySearchTree class should implement the following public methods: 1. A no-arg constructor that creates an empty tree. 2. The method: public void insert(String state, int population) that will insert a node into the proper position in the search tree based on state name. 3. The method: public int find(String state) that will search the tree for the state of the given name and if found will return the population or -1 if not found. 4. The method: public void delete(String state) that will find and delete the given state from the tree. 5. The method: public void printInorder() that will traverse the tree in using a Inorder traversal (LNR) and print each node. COP3538 Project 4 Binary Search Trees Liu University of North Florida 2 6. The method: public void printPreorder() that will traverse the tree in using a Preorder traversal (NLR) and print each node. 7. The method: public void printPostorder() that will traverse the tree in using a Postorder traversal (LRN) and print each node. 8. The method: public void printMinimum() that will find and print the state with the minimum population. 9. The method: public void printMaximum() that will find and print the state with the maximum population. (2) . Create a class called Project4 that will 1. Read a file (csv) of states and create a binary search tree by calling the insert method. 2. Inorder traverse the tree and print all nodes using the printNode method as they are visited. 3. Delete states California, Florida and Michigan from the tree by calling the delete method; and preorder traverse the resulting tree printing all nodes as they are visited. 4. Search for states Kentucky, Rhode Island and Florida by calling the find method. For each search, print the population information of the found states, and not-found message if not found. Note, for each search, you will also print the number of non-leaf nodes visited to have or havent found the target state. 5. Delete states Delaware,Wyoming, West Virginia and South Dakota from the tree, and postorder traverse the remaining tree printing all nodes as they are visited. 6. Print the states with the minimum and maximum population in the tree by calling the printMinimum and printMaximum methods, respectively. Provide comments in this form for the BinarySearchTree classes: Comments for the class: /** * Detailed description of the class. * * @author * @version */ Public method comments: /** * Description of the purpose of the method, the meaning of the COP3538 Project 4 Binary Search Trees Liu University of North Florida 3 * input parameters (if any) and the meaning of the return values * (if any). * * @param parameter description of the parameter (one for each) * @return description of the return value */ Provide comments in this form for the Project4 class. /** * COP 3538: Project 4 Binary Search Trees *

* Description of the class using as many lines as needed * with

between paragraphs. Including descriptions of the * input required and output generated. * * @author * @version */ public class Project4 {

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!