You need to define two methods: min(Tree) and max(Tree) , then span(Tree t) is defined as max(t) - min(t) . span itself does not have to be recursive, but you can make min and max recursive if you want.
Note that min and max should not be their own methods. If you do not want them to stand as their own units, you can put it all in a span as follows:
int span(Tree t) { Tree tMin = t; while (tMin.left != null) { tMin = tMin.left; } Tree tMax = t; while (tMax.right != null) { tMax = tMax.right; } return tMax.key - tMin.key; }
source share