Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started