| COMP1011 Exercises for Week 11 | |
|---|---|
| Computing 1A 05s2 |
Last updated
Tue 19 Jul 2005 14:37
Mail cs1011@cse.unsw.edu.au |
For this week's lab exercises, create a file Lab11.hs. In
this file enter the function definitions appearing in the exercises
below. Then, following the function definitions, in a multi-line
comment, enter the derivation for the timing function and the proof that
the function is in a certain O-class. So,
overall, the structure should be as follows:
foo :: <some type signature>
foo ...<definition of the function>
{- ------------
DERIVATION OF T_...
PROOF:
-}
Given the following function definition:
foo:: [Int] -> Int foo [] = [] foo (x:xs) = (bar xs) + (foo xs)
Ord a => [a] -> [a]
bubbleSort:: Ord a => [a] -> [a]
bubbleSort xs
| xs == xs' = xs
| otherwise = bubbleSort xs'
where
xs' = bubble xs
bubble (x:y: xs)
| x < y = x : (bubble (y:xs))
| otherwise = y : (bubble (x:xs))
bubble xs = xs
When you have completed the above exercise show it to your tutor for this week's advanced mark.