CMPS 13H: Honors Introduction to Programming and Data Structures

Programming Assignment #4: Sets


Remember: your programming assignment must be turned in online.

The Basics

In mathematics, a set is an unordered collection of distinct items. Sets support the addition and removal of items, equality, subset, superset, and union and intersection.

Note that:
  • addition and removal of items are operations on a set and and item that return a new set
  • equality, subset, and superset are operations on two sets that return a boolean value
  • union and intersection are operations on two sets that return a new set

  • The Details

    You should implement a set class that supports all of the above operations. Assume that the items are integers, and use an array of size 100 to store them (our sets will have a fixed maximum size, but that's ok for now). In addition to the operations mentioned above, include a method called size() that returns the size of the set.

    You should also implement a program called UseSet that uses sets. It should call each method of your set class at least once, and print out results showing that it works. You might want to include a toString() method in your set class, as this will facilitate printing out your sets.

    Your program should include a Makefile that compiles the different parts of your program.

    Your program must be accompanied by a one page ASCII document (.txt format) that shows your design:

    1. Inputs
    2. Outputs
    3. Data objects and all non-trivial operations on those data objects
    4. Algorithm(s)

    Your program must also contain clear and descriptive variable names and comments, and good formatting that enhances the clarity of the program.


    What to turn in

    Your java program (called Set.java), a program that exercises your set class (called UseSet.java), your makefile (called Makefile), and your design document (called Design.txt).

    REMEMBER: Do not submit object files, assembler files, or executables. Every file in the submit directory that could be generated automatically by the compiler or assembler will result in a 5 point deduction from your programming assignment grade.


    sbrandt@cse.ucsc.edu