Question: without using any recursion only using the tree_fold function given in ocaml. type 'a tree = | Node of 'a tree * 'a * 'a

without using any recursion only using the tree_fold function given in ocaml.
type 'a tree = | Node of 'a tree * 'a * 'a tree | Leaf let rec tree_fold f init tree = match tree with | Leaf init |Node (1,v,r)f( tree_fold f init 1)v (tree_fold f init r ) trim tree n - Type: ("a tree int 'a tree) - Description: Using tree fold write a function that takes in a complete binary tree tree and an integer n, and trims off nodes at the bottom of the tree such that the depth of the returned tree is at most n. - Examples: compose tree - Type: (('a -> 'a) tree -> 'a -> 'a) - Description: This function will take in a tree that contains ( (a> ' a ) functions as the value in the nodes and returns a function that is the inorder composition of the nodes. You must implement this function using tree_fold. - Examples: Consider the following diagram of a tree. The result of calling conpose on this function would be equivalent to (fur xh(y(f(g)(vx)))) ) Can someone write these 2 functions 1. Compose and 2. Trim using tree_fold(given) and without using any recursive helper functions in Ocaml
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
