--
You received this message because you are subscribed to the Google Groups "EOPL3" group.
To post to this group, send email to eo...@googlegroups.com.
To unsubscribe from this group, send email to eopl3+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/eopl3?hl=en.
Yes, follow the grammar to guide you in the development of the
recursive function.
> The function max-interior returns a symbol so I can’t see how I could
> use its result in a recursive calculation.
It sounds like you need an auxiliary function that returns something
you need (i.e., not a symbol).
>
> Max-interior should be something like this:
> (define max-interior (b)
> (cases bintree b
> (leaf-node (num) …)
> (interior-node (key left right)
> …)))
>
Where is your contract for max-interior? Assuming this function
returns the symbol of the subtree with the max leaf-sum, then it seems
reasonable to compare the leaf-sum of b, the leaf-sum of the
max-interior node of left, and the leaf-sum of the max interior node
in right. Implicit in my hint and described in the problem statement,
is the fact (which should appear in your contract) that max-interior
is always called with a tree that has at least one interior node. In
other words, calling max-interior with a leaf-node should generate an
error.
I hope that helps.
--
Cheers,
Marco