Upon completion of this lab, you should be able to understand the linked list implementation of the Binary Tree ADT and implement some binary tree operations.
LinkedBinaryTree.java, change all usage of the attributes of the
BinaryTreeNodeclass (such as root.left) in the provided code, to invocations of the getter and setter methods you wrote in Exercise 1.
contains. Hint: use
postorder. Hint: Model your code for these on the methods
inorder. The main thing that you need to change is where the node is visited in preorder and postorder.
toString. Hint: printing the data elements of the tree is basically just a traversal of the tree. Choose one of the traversal orders (preorder, inorder, or postorder) and use exactly the same idea of using a temporary unordered list as in the provided method
iteratorInOrder: create a new unordered list, call the method
postorder, which will add the elements of the tree to the unordered list, call the
toStringmethod on the unordered list.
iteratorLevelOrder. However, you will need to return something from within the body of this method in order to have the code compile: just have it return null.
LinkedBinaryTree.java; it is in the file LBTConstructor.txt, and is used to build the sample tree in
TestBinaryTree.java. Check the comments in the code for
TestBinaryTree.javato see what the constructed tree looks like.