CSE 305 Homework #4 Due July 24, 11:59:59pm

  1. Filename: set.sml (10 points each)
    A set is a collection of distinct elements with some implicit ordering. Using the following datatype declaration:
    datatype ''a set = set of ''a list * (''a * ''a -> bool);
    a set can be created, as follows: set([1,2,3], op <);

    Write the following functions that work with sets:

    Solutions for insert, intersection, union, and difference, must preserve the ordering and must be O(n). Since the lists are kept sorted a O(n) solution is possible.

  2. Filename: dup.cl(10 points each)

    Text, exercise 10.4, in Common Lisp. Use these fuction names:

  3. Filename: leaves.cl (20 points, 10 + 10)
    Exercise 10.10 in Sethi, pg. 420 implemented in Common Lisp Name the first function, same-leaves and the second same-leaves-lazy