For parts A-2 and A-3 please see the attached PDF, A2-A3 Response.pdf.
- I've changed the
insertmethod arguments to include only akeyanddata(value). This is because the root of the tree is already stored as a field in the class, so it is redundant to require the user to pass it each time they want to add a node to the linked list. Additionally, a proper binary search tree should have data associated with keys, so myNodeclass has fields for both. The insert method lets you insert a new node with a certain key containing data. - I've changed the
preorderRecmethod to return instead of print out the preorder of the binary search tree. I've also renamed the method topreorder. Likeinsert, it does not require the root node to be passed to it, since it is able to internally utilize the instance fieldrootthrough the gettergetRootNode(). - I've changed
sumto not require the root node, for the same reason I've done so for the other methods. - I've changed
kthBiggestto not require the root node, for the same reason I've done so for the other methods.
For both my linked list and binary search tree, I've given them a package folder to keep them organized, and have implemented corresponding JUnit tests in their respective folders. The test classes have the same names as the original classes, but are suffixed with Test. The tests for respective methods have the same name as the method, prefixed by test. For example, testPreorder tests the preorder method of a BST.