For this week's lab, please implement each of these methods upon the provided BinaryTree class. You'll want to test them thoroughly. But, we don't need to see your test drivers -- we'll use our own. Good luck!
Method Summary | ||||||
BinaryTree |
cloneTree()
Creates and returns an exact copy of the tree. |
|||||
|
int maxLeafLevel()
Returns the level of the leaf that is farthest from the top (root) of the tree.
|
void printLeavesAtLevel(int level)
Prints to the console a list of all items organized at the specified level of the tree.
|
void printPath(java.lang.Comparable keyValue)
Prints the value at each node between and including the root and the supplied keyValue. |
Constructor Detail |
public BinaryTree()
Method Detail |
public BinaryTree cloneTree()
This method does not change any of the items or the structure of the original tree.
In the event of an error, it returns null.
public int maxLeafLevel()
The root is considered to be at level 0.
This method does not change any of the items or the structure of the original tree.
In the event of an error, it returns -1
public void printPath(java.lang.Comparable keyValue)
This method does not change any of the items or the structure of the original tree.
It can print the nodes in any order, but cannot use a collection class.
public void printLeavesAtLevel(int level)
This method does not change any of the items or the structure of the original tree.
It can print all the leaves at the specified level