Basic Binary Tree Lab
CPE 103
This is an individual lab.
Please write neatly on a blank piece of paper.
Write on paper a Java class named TreeLab1 that will
contain a method for each of the following problems.
1. Write on paper the Java statements for a method to build the tree
in Diagram 1 (below) using only Weiss's BinaryNode
class.
public static BinaryNode<Character> problem1()
2. Write on paper the Java statements to build the tree in Diagram 1
using Weiss's BinaryTree
and then print it with post order traverse.
public static void problem2()
3. Write on paper the Java statements to build the tree in
Diagram 2 using Weiss's BinaryTree
.
public static BinaryTree<Character> problem3()
4. Write on paper the Java statements for a method that takes as
input the specific tree created in problem 3 and prints the contents
of the leftmost leaf node.
public static void
problem4(BinaryTree<Character> tree)
5. Write on paper the Java statements for a method that takes as
input an arbitrary BinaryTree of Characters and returns the contents
of the leftmost leaf node.
public static Character
problem5(BinaryTree<Character> tree)
6. Write the code for JUnit tests to verify methods 1, 3, and
5.
Show your work to the instructor. After being approved,
create the TreeLab1 class on the
computer. Implement the JUnit tests and run them.
Correct any defects you discover. Submit TreeLab1 and
the JUnit class to PolyLearn.