View the step-by-step solution to:

Hello, I am currently working on a Data Structures project, to be written in Java. The project is:

 Hello,


I am currently working on a Data Structures project, to be written in Java. I am not very familiar with what is being asked, and would like help. The project is:


The third programming project involves writing a program that performs several operations on a binary search tree. The program should take as input a list of integers or characters and be able to sort lists of integers or lists of characters in either ascending or descending order. One set of radio buttons should be used to determine whether the lists contain integers or characters and a second set should be used to specify the sort order. Moreover, the program should be able to calculate the height of the tree. The main class should generate a GUI with a field for input of characters or integers, a Perform Sort button, a Calculate Height button, an output field which will display the sorted characters or integers, a field that will display the calculated height, and teh radio buttons. Pressing the Perform Sort button should cause all the numbers or characters in the original list to be added to a binary search tree. Then an inorder traversal of the tree should be performed to generate the list in sorted order and that list should then be displayed in the sorted list text field. In addition to the main class that defines the GUI, you should have a generic class for the binary search tree. That class needs a method to initialize the tree, one that allows a new value to be inserted in the tree and one that performs an inorder tree traversal that generates and returns a string that contains the tree elements in sorted order. The insert method does not need to rebalance the tree if it becomes unbalanced. It should allow duplicate entries and it must be written using recursion. It is not necessary to have a method to delete a node from the tree nor one to check whether a particular value is in the tree. Moreover, a method to calculate the height of the tree should be present in the binary search tree class. The third class required for this project is one that defines characters. It should have a constructor that accepts a character. It must implement the Comparable interface, which means a compareTo method is also required.


Please let me know if you are able to help.


Thank you.

Top Answer

TreeNode: //generic class for the BST node declaration public class TreeNode < T > { //for the sorted information    ... View the full answer

fraction.PNG

sort_ascending.PNG

Sort_descending.PNG

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online