> Tree t10 = new Tree(10); // creates a tree with no children > Tree t30 = new Tree(30); > Tree t20 = new Tree(20, t10, t30); // creates a tree with 2 children > Tree t60 = new Tree(60); > Tree t70 = new Tree(70, t60, null); // creates a tree with 1 child, a left child > Tree t50 = new Tree(50, null, t70); // creates a tree with 1 child, a right child > Tree tree = new Tree(40, t20, t50); > tree.printTree(); 10 20 30 40 50 60 70
sumOfChildren which returns the sum of the integers in a tree's immediate left and right children (if they exist). These interactions should work:
> t10.sumOfChildren() 0 > t70.sumOfChildren() 60 > tree.sumOfChildren() 70
min that assumes the tree is a binary search tree and returns the smallest data item in the tree.
It should behave as shown below.
> tree.min() 10 > t50.min() 50 > t70.min() 60