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

  1. Generic program design recipe.
  2. Recursive program design recipe.
  3. 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.

  1. insertionSort

  2. 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: Upload this file using the blackboard assignment mechanism.

Back to the Daily Record.

Back to the class web-page.