SA-6
Exercises
Write an implementation of the Set ADT called BSTSet
that uses the Binary Search Tree (BST.java) from class to store the data. Your Set implementation should conform to this SimpleSet.java interface. Include test cases to show that your implementation works as intended.
Hint: create an instance variable in your BSTSet
class that stores the root of a BST
. You can use the Key
of the BST
to store your Set
's values. You won't need the Value
of the BST
, so you can set it to any type you choose (null is a good choice for the value). To implement the Set
functionality, call BST
methods using the root of the BST
. Do not try to extend BST
to implement Set functionality.
Hint 2: for the iterator
method, you might find it easiest to do an inorder traversal of your BST and store the items in a List. You can then use the List as a basis for your iterator.
Submission Instructions
Turn in your completed Java code with test cases. If you create multiple files, combine them into a single .zip file. If you include your test cases in your BSTSet
class, there is no need to zip this one file.