This assignment makes use of the files contained in this zip file. This assignment is due Thursday, January 23.
This assignment is based on the examples from the first week of class. It is meant to be a review of binary tree algorithms, recursion, and elementary parsing. There are two parts to this assignment.
In the zip file there is a file Tests_Part_1.java
that you need to complete. Follow the directions given in that file.
Also in the zip file there is a file PrettyPrinter.java
which formats as strings the binary trees created by the BuildBTree.java
program. But this pretty-printer is too verbose, it takes too many lines to print a binary tree. For the second part of this assignment you should write a better pretty-printer, and call it PrettyPrinter2.java
. Look in the zip file at the file Tests_Part_2_output.txt
, which is sample output from the program Tests_Part_2.java
, to see how the new pretty-printer should format a binary tree. Notice that the new pretty-printer should put the left sub-tree "inline" with the root and it should also handle the special case when depth=1. Also, notice that a pretty-printer is essentially a pre-order traversal of the binary tree.
When you have finished implementing PrettyPrint2.java
, then the file Tests_Part_2.java
should compile and run. The output from running this program should look exactly like the file Tests_Part_2_output.txt
.
The file BTree.java
defines the BTree
data type for you and the file BuildBTree.java
builds a BTree
data type from its string representation. Your implementation of PrettyPrinter2.java
should use these two programs without making any changes to them.
Turn in a zip file called CS502Hw1Surname.zip
(where Surname
is your last name) containing your versions of Tests_Part_1.java
and PrettyPrinter2.java
(just those two files).
This assignment is due Thursday, January 23.