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) In C, with suitable Node and Tree structs, you could implement it as: int diameter(Tree * t) // post: return diameter of t { if (t == 0) return 0; int lheight = height(tree->left); int rheight = height(tree->right); int ldiameter = diameter(tree->left); int rdiameter = diameter(tree->right); return max(lheight + rheight + 1, max(ldiameter,rdiameter)); } 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 ?. 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 DiameterPair combine(NodeInt t, Integer d, DiameterPair l, DiameterPair r){ return new DiameterPair(Math.max(l.get_height(), r.get_height())+1, Math.max(l.get_height() + r.get_height() +1, Math.max(l.get_diameter(), r.get_diameter()))); } }