Question: This should be done in Haskell! 3. (a) [10%] Implement a function for merging two sorted list of Integers: mergeLists :: [Integer] -> [Integer] ->

This should be done in Haskell! 3. (a) [10%] Implement a functionThis should be done in Haskell!

3. (a) [10%] Implement a function for merging two sorted list of Integers: mergeLists :: [Integer] -> [Integer] -> [Integer] That is, given two sorted lists (i.e., in ascending order), the function returns a list con- taining all the elements in the argument lists in sorted order (i.e., ascending order). An example is the following: mergeLists [1,3,5] [2,4,6] - [1,2,3,4,5,6] (b) [10%] Implement a function that slits a given list into two lists, such that the first returned list contains those elements of the argument list at an even index, and the second list contains those at the odd index. Indices are zero based (i.e., the head of a list has index zero). splitList :: [Integer] -> ([Integer], [Integer]) The following is an example. splitList [4,6,3,1,2,10] ~y ( [4,3,2], [6,1,10] ) splitList [7, 1, 4] ~ ( [7,4], [1] ) splitList [4] ( [4], [] ) splitList [] m ( [], [] ) (c) [5%] Implement a function that performs merge sort. mSort :: [Integer] -> [Integer] Your implementation must call the mergeLists and splitList functions imple- mented in parts (a) and (b). 3. (a) [10%] Implement a function for merging two sorted list of Integers: mergeLists :: [Integer] -> [Integer] -> [Integer] That is, given two sorted lists (i.e., in ascending order), the function returns a list con- taining all the elements in the argument lists in sorted order (i.e., ascending order). An example is the following: mergeLists [1,3,5] [2,4,6] - [1,2,3,4,5,6] (b) [10%] Implement a function that slits a given list into two lists, such that the first returned list contains those elements of the argument list at an even index, and the second list contains those at the odd index. Indices are zero based (i.e., the head of a list has index zero). splitList :: [Integer] -> ([Integer], [Integer]) The following is an example. splitList [4,6,3,1,2,10] ~y ( [4,3,2], [6,1,10] ) splitList [7, 1, 4] ~ ( [7,4], [1] ) splitList [4] ( [4], [] ) splitList [] m ( [], [] ) (c) [5%] Implement a function that performs merge sort. mSort :: [Integer] -> [Integer] Your implementation must call the mergeLists and splitList functions imple- mented in parts (a) and (b)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!