CSI247: Lab 7 - Tree Introduction: Folder Structure (5 Marks)
CSI247: Lab 7 - Tree Introduction: Folder Structure (5 Marks)
In addition, this class should have a constructor that takes parameters for all the instance variables.
The methods from the TreeNode and Comparable should be implemented as follows:
1. size(): This will return the number of children in the node.
2. isRoot(): Check if the parent has a null value.
3. contains(): This method should go through the children in the node and check if one of the
children has the data, if so, return the reference of the child node. If no child contains the
data, return null.
4. addChild(): Create a new TreeNodeImpl object and add it to the children then return the
node.
5. compareTo(): Compare the tree nodes by the comparing the data contained in the nodes.
NOTE: An extension would also be to make sure that the children are also the same. But for
this lab, we are not going to do that.