CSSE 230: Binary Search Tree Exercise - Part 3
- Continue to work on this project by yourself.
- Continue work on the BST project by adding to the BinarySearchTree
class a boolean remove(T element) method which receives an
element of the parameterized Comparable type T and returns
true if the element was successfully removed. When removing a node
with two children, replace its value with the largest element in its
left subtree. Ensure that the recursion takes place in the BinaryNode
class. Please notice that the recursive remove method in the
BinaryNode class will have BinaryNode as a return type. You may not
modify the BinaryNode class so that it maintains pointers to the
parent node. Please ensure that your code is concise and well written.
This method has to throw an IllegalArgumentException if you pass it a
null argument.
- Ensure that your remove method in the
BinaryTree/Node
class is thread-safe when it comes to the return type. In other
words, you cannot have some global variable which captures whether an
element was successfully removed. Instead, the remove method of the
BinaryNode class needs to have an additional, mutable
parameter. Furthermore, your recursive remove method is not permitted
to throw an exception when the element to be removed is not found and
you may not use a "contains" method to check whether the element to be
removed is in the tree or not, as this decreases the efficiency.
- Please use the following test-suite to
test your software.