Homework #1 - Sorts over Arrays
In this home work we will write two sorting algorithms over
arrays. An insertion sort, and an exchange sort. You are
required to follow the steps of the design recipes
we have studied in class.
Recall that every step in a design recipe cooresponds to a product. It must
be the case that every product appears in your solution. It could be a comment,
or some actual program fragment. Study the design recipes
- Generic program design recipe.
- Recursive program design recipe.
- Array processing design recipes.
For this homework you will create one haskell program which
defines two functions. Study the problem description below for each function.
Note that you are required to write two functions. You may write additional
helper functions if you desire. You must include tests, and you must include
a "main" function that acts as a "harness" and demonstrates (in addition to your tests)
that the two functions work.
- insertionSort
- exchangeSort
Getting Started.
You will need to download the library file ArrCommands
and put a copy in the same directory as your solution.
Your program will probaby look something like
-- Author Tom Smith
module HW02 where
import ArrCommands
insertionSort:: Array a -> IO ()
exchangeSort:: Array a -> IO ()
main =
do { ... }
tests = ...
What to turn in.
Create a Haskell source file. Upload the file to blackboard
by class time October 20, 2009. The file must have:
- Your name (as the author of the program) indicated in a comment in the very first line
- At least 2 function definitions, one for each of the assigned functions.
You may define additional functions to help, or to create tests.
- Products for each of the concrete steps in the generic design recipe
- Understand the problem
- Write a contract (type) for each function
- Create a set of examples (HUnit assertions)
- Create a body for each function where the body
is based upon one of the design recipes above.
- Tests for each your functions (HUnit tests) including a named value "tests" that runs all your tests.
- A "main" function that acts as a "harness" and demonstrates (in addition to your tests)
that the two functions work.
- Any products from the recursive design recipe you deem to be usefull to the reader of your program.
Upload this file using the blackboard assignment
mechanism.
Back to the Daily Record.
Back to the class web-page.