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.
- Implement 3.8 f (mergesort) in Haskell.
- Implement 3.26 a,c in Haskell.
- 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.
- Implementation in Haskell
- Implementation in ML
- Implement the following in Prolog:
- 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.
| ?- min(10,[1,2,3,4,5]).
| ?- min(1,[1,2,3]).
| ?- min(X,[2,5,1,4,2]).
X = 1 ?
- 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
| ?- sentence([the,boy,pets,a,dog]).
| ?- sentence([the,girl,sees,a,cat]).
| ?- sentence([girl,pets,boy]).
- (Extra credit) Implement addition and multiplication for Church numerals in Haskell.
Each programming problem is worth 25 points (also extra credit).
- Assignments must be submitted via Email.
Email the Assignment to email@example.com
CC a copy to Professor Nowak firstname.lastname@example.org
The Title of the Email must be [CS360] Programming Assignment 2
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
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.
- 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.
- Each file should contain:
- Your Name
- Comments documenting all functions included in the file
- Your function definition
- Tests for your functions
- Submit a readme file containing the following:
- Your Name
- Email Address
- Example Execution Traces testing each of your functions
- All your code MUST run on tux.cs.drexel.edu.