lease use the standard ML of New Jersey to complete this. Do not use     Here is an SML mergesort program: ----------------------------------------------------------------------------------------------  fun merge([], ys) = ys  | merge(xs, []) = xs  | merge(x::xs, y::ys) =  if x < y then x::merge(xs, y::ys)  else y::merge(x::xs, ys)  fun split [] = ([],[])  | split [a] = ([a],[])  | split (a::b::cs) =  let val (M,N) = split cs in  (a::M, b::N)  end  fun mergesort [] = []  | mergesort [a] = [a]  | mergesort [a,b] = if a <= b then [a,b] else [b,a]  | mergesort L =  let val (M,N) = split L  in  merge (mergesort M, mergesort N)  end --------------------------------------------------------------------------------------------------- Note that mergesort includes three base cases ([], [a], [a,b]) and all are handled correctly. Suppose we delete the third line of mergesort, so that [a,b] is no longer handled as a base case. You can verify that this change makes no difference in the type of mergesort or in its behavior. Now suppose we also delete the second line of mergesort, leaving -----------------------------------------------------------------------------------  fun mergesort [] = []  | mergesort L =  let val (M,N) = split L  in  merge (mergesort M, mergesort N)  end ---------------------------------------------------------------------- What effect does this change have on the type that SML infers for mergesort? Verify that whether updated mergesort works correctly by running on your system and explain your findings.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter13: Structures
Section13.5: Dynamic Data Structure Allocation
Problem 6E
icon
Related questions
Question

Please use the standard ML of New Jersey to complete this. Do not use

 

 

Here is an SML mergesort program:

----------------------------------------------------------------------------------------------
 fun merge([], ys) = ys
 | merge(xs, []) = xs
 | merge(x::xs, y::ys) =
 if x < y then x::merge(xs, y::ys)
 else y::merge(x::xs, ys)
 fun split [] = ([],[])
 | split [a] = ([a],[])
 | split (a::b::cs) =
 let val (M,N) = split cs in
 (a::M, b::N)
 end
 fun mergesort [] = []
 | mergesort [a] = [a]
 | mergesort [a,b] = if a <= b then [a,b] else [b,a]
 | mergesort L =
 let val (M,N) = split L
 in
 merge (mergesort M, mergesort N)
 end

---------------------------------------------------------------------------------------------------

Note that mergesort includes three base cases ([], [a], [a,b]) and all are
handled correctly.
Suppose we delete the third line of mergesort, so that [a,b] is no longer handled
as a base case. You can verify that this change makes no difference in the type of
mergesort or in its behavior.
Now suppose we also delete the second line of mergesort, leaving

-----------------------------------------------------------------------------------
 fun mergesort [] = []
 | mergesort L =
 let val (M,N) = split L
 in
 merge (mergesort M, mergesort N)
 end

----------------------------------------------------------------------
What effect does this change have on the type that SML infers for mergesort?
Verify that whether updated mergesort works correctly by running on your
system and explain your findings. 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Returning value from Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning