Implement a generic binary tree class using an internal node class to store the elements. (BinTreeUMUC and NodeBinTree).

Specific requirements include:

  • Implement a driver class for the BinTreeUMUC class. There should be appropriate comments in the source code files. Exceptions should be thrown when necessary.
  • Define a data file format to specify a binary tree and create at least one such input file (which will be used to test your program)
  • Use the menu based approach you defined in Week 1 to test your stack class. Methods for BinTreeUMUC
  • BinTreeUMUC (Scanner) create a tree from a Scanner tied to a file
  • BinTreeUMUC () no-parameter constructor
  • N getRoot ()
  • String toPreOrderString () collects nodes in preorder
  • String toInOrderString () collects nodes in inorder
  • String toPostOrderString () collects nodes in postorder
  • String toLevelOrderString () collects nodes level after level starting with the root
  • int countNodes() counts all the nodes
  • int countLeafs() counts the leafs
  • int countLeft() counts the nodes that have only the left child (right child is null)
  • int countRight() counts the nodes that have only the right child (left child is null)
  • int countNodesLevel(int) counts nodes from a certain level given as parameter
  • Add other methods if needed

Create a test report (bintree.doc/docx/pdf/) showing the correct behaviour of all the methods; include a description of the design and lessons learned; include screenshots of your running program. (the testing procedure will be provided soon)

Deliverables:

  • input file(s)
  • the Java source code files
  • the test report files (bintree.doc/docx/pdf)

Note: this is a general binary tree, no order between its nodes exists. PS: The testing procedure for your program is given below. Given the tree below: See image.

Create the input file that describes this tree using your chosen input data format (Make sure to describe in your report document report.doc the format you use for representing a tree in an input file). Select the menu option for loading the input file and creating a tree in the main memory.

Call the following functions (using your menu):

  • String toPreOrderString () collects nodes in preorder
  • String toInOrderString () collects nodes in inorder
  • String toPostOrderString () collects nodes in postorder
  • String toLevelOrderString () collects nodes level after level starting with the root
  • int countNodes() counts all the nodes
  • int countLeafs() counts the leafs
  • int countLeft() counts the nodes that have only the left child (right child is null)
  • int countRight() counts the nodes that have only the right child (left child is null)
  • int countRight() counts the nodes that have only the right child (left child is null)
  • int countNodesLevel(int) counts nodes from a certain level given as parameter and record the results in your report document (report.doc) using screenshots from your Project.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.