$25
HW 5 Binary Tree traversals
Documentation: Every file should begin with a header comment that describes the purpose of the file and includes your name. Each method must be preceded by something like: /** * methodName and what it accomplishes * @param variableName and what it is for- include for each parameter * @return required for value returning methods, what is being * returned? */ If there are preconditions required or exceptions thrown, those must also be described. ---- Problem description: Modify the author’s BinarySearchTree class (see General Resources on piazza). 1. Add 3 printTree methods (discussion in section 4.6 in text) a. printTreePre displays tree contents in pre-order. b. printTreePost displays tree contents in post-order. c. printTreeLevel displays the tree contents in level-order. (Details of this one below) printTreeLevel algorithm: Use a queue (a LinkedQueue from HW 4 will work fine) of Node type,. If the tree is not empty Enqueue the tree’s root node While the queue is not empty, Dequeue a node; Output the node’s data value If the nodes’s left child is not empty, enqueue the node that is the left child If the node’s right child is not empty, enqueue the node that is the right child 2. Write a main method that instantiates multiple binary search trees and displays the results of all printTree algorithms on each tree. Your output should be clearly labeled. Include an empty tree in your testing.