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)
Try it now!
How it works?
Follow these simple steps to get your paper done
Place your order
Fill in the order form and provide all details of your assignment.
Proceed with the payment
Choose the payment system that suits you most.
Receive the final file
Once your paper is ready, we will email it to you.