For this assignment, you will generalize the BinaryTree class to allow for more than one data value to be stored in a node. A multitree of degree N will allow for N-1 values to be stored in a node, with N children nodes. Thus, a binary tree is a multitree of degree 2 (with 1 data value per node and 2 children nodes). A partial implementation of the MultiTree class is provided for you. Implement the following methods (without modifying the exiting constructor and methods):
Once you have written and tested these method thoroughly, write a driver that generates random multitrees and reports the average heights and weights of those trees. For each of the degrees 2 through 6, you should generate 1000 different multitrees of that degree. Each multtitree should have 100 random numbers added to it. Use your driver to complete the table below:
average height | average weight | |
---|---|---|
degree=2 | ||
degree=3 | ||
degree=4 | ||
degree=5 | ||
degree=6 |