Homework Five
Tree Pretty Printing
Due: Thursday March 3
I am creating a program that uses a binary tree. For debugging
purposes, I need a function that will print the contents of a
tree in a format where the structure of the tree is evident.
In other words, I not only need to see the values in the tree,
but also what values are to the left and right of each other.
I created
this test code
to build a small tree that looks like this:
20
/ \
10 40
/
30
Your job is to write the print_tree function to create output
such as:
node 20 -- left child is 10, right child is 40
node 10 -- left child is null, right child is null
node 40 -- left child is 30, right child is null
node 30 -- left child is null, right child is null