Programming Assignment 1 (due midnight 07/23/14)

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

Problem I (50 points). Implement, document (i.e. provide specifications), and test the following functions in Scheme. Scheme has implemented some of the constructs below (iota, association lists) - you may not use these implementations, but rather must implement them yourself. Make sure all functions are thoroughly tested.

  1. Write a scheme function (iterator (start step end)) which returns a function which when repeatedly called returns the numbers in the sequence (range (start step end)). When the sequence is exhausted the returned function should return ().
    Example: (define next (iterator '(0 2 7))), (begin (next) (next) (next) (next) (next)) => 0, 2, 4, 6, ()
  2. An association list is a list of bindings of names to values: ((name1 val1) ... (name t value t)). This data structure can be used to implement a symbol table. An environment can be represented by a list of association lists (i.e. a list of symbol tables), where the first element in the list is nearest scope, the second the next surrounding scope, and the last the outermost scope.
    1. Write recursive scheme function (lookup name assoc_list) that returns the binding (pair) whose name equals the given name. If no such binding is found return the null list.
    2. Write a recursive function (lookup-env name environment), which returns the binding with the specified name in an environment (i.e. list of association lists) and null if no such binding is found.

Problem II (50 points). Prepare a framework for timing BST search operation applied to random BSTs implemented in C++, Scheme and ML, perform a series of timing experiments and draw conclusions out of your experiments. Mark’s website contains examples explaining how to perform timing in Scheme and ML. CS 265 website (https://www.cs.drexel.edu/~knowak/cs265_spring_2014/cs_265_links.htm) contains code (https://www.cs.drexel.edu/~knowak/cs265_spring_2014/code_part_1.zip) and explanations related to random C++ BSTs.

1.      Write C++/Pyton code that prompts the user for an input integer n, creates a vector/list consisting of numbers 0,1,2,…,n-1, runs the STL/Python library algorithm random_shuffle/random.shuffle on it in order to create a random permutation of size n and then stores it in a file.

2.      Write C++, Scheme and ML code that reads a random permutation from a provided file and then inserts its numbers one-by-one into an initially empty BST. Once the BST is created the code should compute its height, the number of nodes and the total time spent on searching for all of its items.

3.      Run a series of representative timing experiments, report them in the form of a table or graphs, draw your conclusions, write them down and submit together with your code.


You will need to submit your code and reports following the submission rules that will be provided at a later date
.