Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

. ( 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Identify and implement the three phases of the writing process.

Answered: 1 week ago

Question

identify current issues relating to equal pay in organisations

Answered: 1 week ago