Ropes are a persistent data structure that stores text in a tree-like structure. Consider the following definition of ropes. type rope ? | EmptyRope | StringRope of string | RopeNode of rope × rope function rope-concat(a, b) is // Concatenate ropes a and b RopeNode(a, b)
(a) (15 pts) Write a function to return the length of a rope. Assume you have a function to find the length of a string, strlen : string 7? N and that the running time of strlen is constant. Then, your function should have a running time of O (n), where n is the number of RopeNode’s in the rope. You may use OCaml syntax or pseudocode of the style used in lecture to write your function. (
b) (15 pts) Use structural induction to prove that your function has a running time of O (n)