Question: Assume that the data type tree is defined as in problem 4. Write a function that combines all the values of the leaves by using
Assume that the data type tree is defined as in problem 4. Write a function that combines all the values of the leaves by using the binary operation passed as a parameter. In more detail, if oper : a * a ? a and t is the nonempty tree on the left in this picture,

then reduce oper t should be the result we obtain by evaluating the tree on the right. For example, if f is the function: fun f(x : int, y : int) = x + y;
then reduce f (NODE( NODE( LEAF 1, LEAF 2), LEAF 3)) = (1 + 2) + 3 = 6. Explain the definition of reduce in one or two sentences.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
