Our items to be stored and compared in this lab will be strings. For testing purposes, I recommend using single letters as entry, however, full words can also be used.
Methods that remain to be implemented in the TreeNode
class have been
marked with TODO for easy identification.
insert()
and contains()
insert()
and contains()
methods in
the TreeNode
class. The test case BinarySearchTreeTester.test1()
should pass if your solutions are correct.
height()
, size()
, getMin()
,
and getMax()
methods in the TreeNode
class. Then
run BinaryTreeApp
. As you add nodes to your tree, you should see the statistics updated on the left. Make sure the values are correct by experimenting with different tree structures.
preOrder()
, postOrder()
, and inOrder()
methods in the TreeNode
class. The parameter is a
Consumer
object that performs an operation on each value.
They should pass their unit tests, and also you can test them in
BinaryTreeApp
.
remove()
method. Note that it does not return the
removed node; it returns the node upon which it was invoked, and rebuilds the
tree as it exits from its recursive calls. Follow the comments carefully.
It should pass its unit tests and again is testable on the GUI, by clicking on
nodes you wish to remove.
remove()
, these methods return the
rebuilt tree nodes.
Cumulative Progress | Points Earned |
---|---|
Step 1 | 8 |
Step 2 | 11 |
Step 3 | 13 |
Step 4 | 15 |
Step 5 | 17 |
Step 6 | 20 |