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: minltree and rangeltree. DO NOT USE RECURSION!!! Use a higher order function to solve like List.foldleft
Consider the tree type from Homework here renamed to ltree.
type 'a ltree Leaf
I Branch 'a Itree 'a ltree
From Homework reimplement the following functions using higher order functions instead of recursion, but on the ltree type
defined above:
minltree : int ltree int
This should return the minimum value of the tree, ie
minltree Leaf
minltree BranchBranchLeaf Leaf BranchLeaf Leaf
rangeltree : int ltree int int
This should return a pair containing the minimum and maximum value of the tree, ie:
rangeltree Leaf
rangeltree BranchBranchLeaf Leaf BranchLeaf Leaf
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
