Write a function to return the length of a rope

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. (

Don't use plagiarized sources. Get Your Custom Essay on
Write a function to return the length of a rope
Just from $13/Page
Order Essay

b) (15 pts) Use structural induction to prove that your function has a running time of O (n)

Place Order
Grab A 14% Discount on This Paper
Pages (550 words)
Approximate price: -
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)