Answered step by step
Verified Expert Solution
Link Copied!

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] ->

image text in transcribedThis 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions

Question

=+1. What is the purpose of the ImageSwitcher?

Answered: 1 week ago

Question

Th e last time I complained, nothing happened.

Answered: 1 week ago

Question

Th ey could have made my situation worse.

Answered: 1 week ago