Question 5:
The diameter of a tree T is the largest of the following quantities:
* the diameter of T's left subtree
* the diameter of T's right subtree
* the longest path between leaves that goes
through the root of T (this can be computed
from the heights of the subtrees of T)
Implement the Diameter computation in a structure-shy way
using DemeterF. Do one traversal of the tree to compute
both height and diameter.
Your function object must correctly compute the diameter for both
cd-pure and cd-with noise from question 1.
Find the UNKNOWN below:
From the class dictionary:
DiameterPair = "height" int "diameter" int.
From the function object:
class Diameter extends IDba{ // type unifying
DiameterPair combine(BSTInt l) {return new DiameterPair(0,0);}
UNKNOWN
}