The BinaryTree.java file contains an implementation of Binary Tree. However, signatures for the following methods are provided but their bodies are not defined.

computer science

Description

Part 1 

The BinaryTree.java file contains an implementation of Binary Tree. However, signatures for the following methods are provided but their bodies are not defined. 


• width(): should compute and return the width of the tree. 

• breadthFirstTraverse(): should traverse the tree in breadth-first order and return a string that represents the breadth-first traversal sequence of the tree. 

• postOrderTraverse():should traverse the tree in post order and return a string that represents the post order depth first traversal sequence of the tree. 

• inOrderTraverse():should traverse the tree in order and return a string that represents the in order depth first traversal sequence of the tree. 


You need to implement the bodies of the aforementioned methods so that they perform the computation in accordance with what they are meant for. For this task you must use your own implementation of queue, that can grow in size when necessary. You must NOT make any other modifications in BinaryTree.java.


Currently the test code in TestBinaryTree.java fails due to empty implementation of the aforementioned two methods. Your implementation, if done correctly, should make all the tests pass. Do NOT modify or submit this provided test code.


Related Questions in computer science category