Download IBinaryTree.java from /home/gtowell/Public206/Lab07. This is a fairly standard implementation of a binary tree except that it is tied Integers and has only an insert method.
Create a driver method for this class. In your driver add: 6, 4, 2, 7, 3, 9, 8, 5 in that order. This will create a tree with the following structure:
6
/-----/ \-----\
/ \
4 7
/-/ \-\ /-/ \-\
/ \ / \
2 5 x 9
/ \ / \
x 3 8 x
Note (x represents null in the horrid graphic above)
)
Implement a method to print the nodes in the tree in numeric order. i.e. 2 3 4 5 6 7 8 9
Implement a method to print the nodes in the tree in reverse numeric order.
Implement a method to print a simple text-based representation of a tree. For example:
6
4
2
x
3
5
7
x
9
8
x
Implement a method that prints out all the nodes a level N prior to all of the nodes at level N+1. The ordering of nodes within each level is arbitrary. So, one possible printout would be 6 4 7 2 5 9 3 8. This is called a breadth-first representation. You will likely need an extra data structure for this task; my implementation uses an ArrayList