Question: let t7 = Fork (Some 1, Leaf (Some 2), Fork (Some 3, Leaf None, Leaf None)) let t8 = Fork (Some a, Leaf (Some b),

let t7 = Fork (Some 1, Leaf (Some 2), Fork (Some 3, Leaf None, Leaf None)) let t8 = Fork (Some "a", Leaf (Some "b"), Fork (Some "c", Leaf None, Leaf (Some "d"))) 

Write 4 new functions

t_opt_size : 'a option tree -> int

Example: t_opt_size t7 gives 3.

t_opt_sum : int option tree -> int

Example: t_opt_sum t7 gives 6.

t_opt_charcount : string option tree -> int

Example: t_opt_charcount t8 gives 4.

t_opt_concat : string option tree -> string

Example: t_opt_concat t8 gives "abcd".

(program in ocaml)

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!