Assignment #22

Instructions

  1. Save these files to your desktop:
    BinaryNode.java
    BinarySearchTree.java
    TreeException.java
    Person.java
    PersonException.java
    Menu.java
    presidents.csv
  2. Compile and run Menu.java
  3. When the "Main Menu" displays, click on the "Node Information" button (circled in green).
    Shopping List Main Menu
  4. When the "Input" box displays, enter the number "1000", and click OK.
    Input box
  5. You should see this output at the bottom of the jGRASP in the console window:
    current node = 1000,689.3,Martha Dandridge Custis Washington
  6. Next, try out these numbers as well: 2000, 3000, 4000. You should see this output at the bottom of the jGRASP in the console window:
    current node = 1000,689.3,Martha Dandridge Custis Washington

    current node = 2000,267.96,Louisa Catherine Johnson Adams

    current node = 3000,-600.47,Letitia Christian Tyler

    current node = 4000,860.22,Jane Means Appleton Pierce

  7. Now, check out the example file, which shows example program output: output22.txt
  8. Your task for this assignment is to write code inside method nodeInformation() in the class BinarySearchTree, which is in the file BinarySearchTree.java. The method should display the following information:
    1. the current node
    2. the type of node (root, internal, leaf)
    3. the left child node
    4. the right child node
  9. Note that the following instructions are only suggestions and only one of many possible code solutions. Please feel free to write your own code, in your own style, using your own ideas as well. Loops, other recursive methods, and other data structures are also possible.
  10. To find the type of node, left child node, and right child node, you need to create a new method getNode(), which is very similar to the get() method. Instead of returning the data of the node (return node.getData()), the getNode() method will return the node itself (return node). So the return type of getNode() will be BinaryNode<T>, instead of T. The parameters of the getNode() method are the same as the parameters of the get() method. From the method nodeInformation(), call the getNode() method, which returns the address of the node. Once you have the address of the target node, you can determine the type of node, left child, and right child, by using if-statements inside method nodeInformation().
  11. Turn in only the file BinarySearchTree.java with your modifications.

    ** Don't forget to put your name, date, and assignment number at the top of the file. **

  12. Write your original comments every 3-5 lines of code.
  13. Make sure your code follows the ICS 211 Java Coding Standard, in particular the Java documentation (Javadoc) comments that go above each method.