Implement some algorithms to sort lists.
Define a function
insert :: [Int] -> Int -> [Int] that, given a sorted
list and an element, correctly inserts the new element in the list.
Define a function isort :: [Int] -> [Int] that
implements insertion sort using the previous function.
Define a function
remove :: [Int] -> Int -> [Int] that, given a list
and an element
,
erases the first occurrence of
from the list. You can assume that the element is always in the
list.
Define a function ssort :: [Int] -> [Int] that
implements selection sort using the previous function.
Define a function
merge :: [Int] -> [Int] -> [Int] that, given two
sorted lists, merges them to get a list with all the elements in sorted
order.
Define a function msort :: [Int] -> [Int] that
implements merge sort using the previous function.
Define a function qsort :: [Int] -> [Int] that
implements quick sort.
Generalize the previous function into
genQsort :: Ord a => [a] -> [a] that sorts elements
of any type.
Each sorting algorithm scores 20 points.
Author: Unknown
Translator: Jordi Petit
Generation: 2026-02-03T17:08:26.069Z
© Jutge.org, 2006–2026.
https://jutge.org