Due: Mon Oct 2, 11pm
How to Submit
Submit a single file named
Your submission must compile without errors in GHCi. Put all non-working parts of your solution in comments.
Please preserve the existing
doctestcomments in the template (the lines starting with
>>>and the results underneath). Also feel free to add your own additional tests!
Read the Homework Policy! This describes what to do if you cannot solve a problem.
In this assignment, you will be defining the functions described in comments in the above template. You should download the template, rename it, and add your definitions directly to the file.
In addition to a one sentence English description of each function, the file contains
doctest comments that illustrate the intended behavior of each function on a few examples. You can use these examples as unit tests using the
doctest tool illustrated in class. Feel free to add more examples to improve your test coverage.
Instructions for installing
doctest are on the course web page.
Part 1: Binary Trees
In the first part of the assignment, you will define several functions for querying, generating, and manipulating binary trees of integers. Some of the problems will also require knowing about binary search trees. For each function, you should:
- Write the appropriate type of the function.
- Implement the function.
Part 2: Run-Length Lists
In the second part of the assignment, you will implement two functions for converting between regular lists of elements and a run-length encoding of lists. The types of the functions are already given, so you only need to implement them.
You may find some of the existing list functions available in the Prelude helpful for this part. You are also free to write as many helper functions as you would like.