Question: . ( 2 points ) Consider the integer tree type type t r e e = | L e a f | Node of t

.(2 points) Consider the integer tree type
type t r e e =
| L e a f
| Node of t r e e i n t t r e e
The simplest way to calculate the sum of an integer tree is:
l e t r e c sum t = match t with
| L e a f >0
| Node ( l , v , r )> sum l + v + sum r
However, this implementation is not tail-recursive. Write a tail recursive function sumtailrec
: tree > int that sums up the integer values in a tree. (Hint: Use an auxiliary function of
type: int > tree list > int ).
Operational Semantics
4.(1 point) Derivations
Fill in the blanks in the derivation tree for evaluating let x =8 in 3> x 4 using the oper-
ational semantics in Fig. 1.
Blank 1:
Blank 2:
Blank 3:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!