PLEASE FOLLOW DIRECTIONS Write recursive merge sort code in Haskell. a) Adapt the firstHalf code from the lecture exampl

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

PLEASE FOLLOW DIRECTIONS Write recursive merge sort code in Haskell. a) Adapt the firstHalf code from the lecture exampl

Post by answerhappygod »

PLEASE FOLLOW DIRECTIONS
Write recursive merge sort code
in Haskell.
a) Adapt the firstHalf code from the lecture example to work
with a list of values of any data type (that is, change the type
signature from [Char] -> [Char] to [a] ->[a])
b) Add a function just like the one from a) except that it
returns the second half of the list.
c) Write a merge function that merges two lists, xs and ys:
Note that the data type of the items in the list must be an Ord,
so the type signature will be:
merge :: Ord a => [a] -> [a] -> [a]
d) Write the function mergeSort. Consider the types for the
function signature. Here is how the function should work. To
mergeSort the list xs:
e)Paste your code and the output in the
window.
USE THIS TESTING CODE
mergeSort []
mergeSort [-1]
mergeSort [5,-1]
mergeSort [5,-1, 42]
mergeSort [5,-1, 42, -1000]
mergeSort ""
mergeSort " "
mergeSort "G"
mergeSort "Godzilla"
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply