CPSC 425 Spring 2008
HW 5: Intro to Grammars and Syntax

    1. Write selection sort in ML as discussed in class. Remember the recursive specification for this algorithm:
      • An empty list is already sorted
      • For a non-empty list, the sorted list is the smallest element in the list followed by a sorted version of the other elements in the list.
      So all you have to do is figure out how to find a) the smallest element in the list, and b) the list with that smallest element removed. You can then sort (b), stick (a) on front of it, and voila! Be sure you use good ML style, including pattern matching and local variables as appropriate.

      E-mail your selection sort code to me before class, and bring hardcopy to class.

    2. Read Webber chapter 2 and do the Chapter 2 exercises below:
      1. #1 (b),(c),(e),(j)
      2. #2 (b),(c),(e),(j)
      Turn these in at the beginning of class. Feel free to handwrite or type them as you prefer.