## Programming Assignment 2 (due midnight 02/19/14)

Penalty for late submission: 10% less credit/day.

Implement, document (i.e. provide specifications), and test all your code. Make sure all your code is thoroughly tested and runs on tux.

1. Implement 3.8 f (mergesort) in Haskell.
2. Implement 3.26 a,c in Haskell.
3. Create a random Binary Search Tree in Haskell and ML. Insert one million random numbers into an empty BST. You can download a random set of numbers here or create your own. Do not try to sort the numbers to get a balanced tree. Insert these numbers one by one into an initially empty BSTs and then compute the number of nodes and the heights of the resulting trees.
2. Implementation in ML
4. Implement the following in Prolog:
1. Create a min function that finds the minimum element in a list.
min(X,L) is true when X is the minimum element of the list L.
Examples:
```| ?- min(10,[1,2,3,4,5]).
no
| ?- min(1,[1,2,3]).
yes
| ?- min(X,[2,5,1,4,2]).
X = 1 ?
```
2. Create a sentence function in prolog.
Sentence(L) is true when the list L contains a valid sentence.
For this assignment, a valid sentence will be defined as follows.
Sentence -> noun_phrase verb_phrase
noun_phrase -> article noun
verb_phrase -> verb noun_phrase
Nouns -> boy, girl, dog, cat
Verbs -> sees, pets
Articles -> a, the

Examples:
```| ?- sentence([the,boy,pets,a,dog]).
yes
| ?- sentence([the,girl,sees,a,cat]).
yes
| ?- sentence([girl,pets,boy]).
No
```
5. (Extra credit) Implement addition and multiplication for Church numerals in Haskell.

Each programming problem is worth 25 points (also extra credit).

## Submission Guidelines

1. Assignments must be submitted via Email.
Email the Assignment to au49@drexel.edu
CC a copy to Professor Nowak kn33@drexel.edu
2. The Title of the Email must be [CS360] Programming Assignment 2
3. Attach all solutions in a single zip or tar.gz file. Name the file username_a2.zip or username_a2.tar.gz where username is your drexel login. For example, mine would be au49_a2.zip. Here is a useful website for making zip/tar.gz/etc in linux
4. In the body of the email list all the files you are submitting. Give the name of the compressed file and a list of the contents. If any files are missing/corrupted, then I will know what you submitted.
5. Submit one text file for each question. You should submit the files: mergesort.hs, allsquares.hs, allperfects.hs, BST.ml, BST.hs, min.pl, sentence.pl and church.hs.
6. Each file should contain: