Question: Use ocaml to solve the functions: min _ ltree and range _ ltree. DO NOT USE RECURSION!!! Use a higher order function to solve like

Use ocaml to solve the functions: min_ltree and range_ltree. DO NOT USE RECURSION!!! Use a higher order function to solve like List.fold_left
Consider the tree type from Homework 02 here renamed to ltree.
type 'a ltree = Leaf of'a
I Branch of 'a Itree * 'a ltree
From Homework 02, reimplement the following functions using higher order functions instead of recursion, but on the ltree type
defined above:
min_ltree : int ltree int
This should return the minimum value of the tree, ie.
min_ltree (Leaf 4)=4
min_ltree (Branch(Branch(Leaf 3, Leaf (-1)), Branch(Leaf 2, Leaf 9)))=-1
range_ltree : int ltree (int ** int)
This should return a pair containing the minimum and maximum value of the tree, ie.:
range_ltree (Leaf 4)=(4,4)
range_ltree (Branch(Branch(Leaf 3,Leaf (-1)),Branch(Leaf 2,Leaf 9)))=(-1,9)

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!