Dana Vrajitoru
C243 Data Structures

C243/A594 Homework 8

Due date: Wednesday, October 30, 2019.

Ex. 1. a. Download the following files (note that the content is somewhat different from Homework 7):
tree.cc
tree.h
interface.cc
interface.h
main.cc
Makefile

a. For this homework, you must supply the code for four of the functions present in the file tree.cc. Copy the function destroyABinaryTree from the previous homework for the file to compile.

The files contain the implementation of a binary tree structure where the datum is an integer and some functions to manipulate it. Moreover, the files contain some functions to test this structure and the manipulation functions. To compile this program you should use the command make and to run the program you should use the command btree.

Note 1. A tree is called height balanced if for every node, the heights of the left and right subtrees don't differ by more than 1. For example, if the left subtree of a node had a height of 4, then the right subtree could have a height of 3, 4, or 5. Empty trees, trees with one node, complete trees, and perfect trees, are all height balanced too.

Note 2. For the function growNewLeaves, if the tree is completely empty, one node should be added to it. To give another example, if the tree is

    3
   / \
  5   6
 /     \
1       9
then it should become
       3
     /   \
    5     6
   / \   / \
  1   0 0   9
 /\         /\
0  0       0  0

Upload to Canvas: the source files that you modified: tree.cc and any other file you change.