CS U370 Assignment #3. Assigned: Friday, 8 October 2004 [corrected!] Due: Friday, 15 October 2004 [corrected a second time!] You will complete an implementation in Java of the IntSet ADT that is specified below. Collaboration between students is forbidden on this assignment. You are responsible for keeping your code hidden from all other students. Part of your grade will be determined by how well you hide your code, part of your grade will be determined by how well you follow the instructions for submitting your code, part of your grade will depend upon the correctness of your code, and part of your grade will depend upon the readability of your code (e.g. formatting and comments). Turn in your work on this assignment before 4 pm on the due date by sending electronic mail to will@ccs.neu.edu with subject CSU370 assignment 3 and a body that consists of nothing but your IntSet.java file. That file should begin with a block comment that lists 1. Your name, as you want the instructor to write it. 2. Your email address. 3. Any remarks that you wish to make to the instructor. Late assignments may be discounted, and very late assignments may be discarded. -------------------------------------------------- Your assignment is to write the code for a single file, IntSet.java, that implements the specification below. Note that IntSet.java must be part of the default package. A small test program will be made available in /course/csu370wc/Assignments/A3 -------------------------------------------------- Specification of the IntSet ADT. The IntSet ADT is an immutable abstract data type. It shall be implemented by a single file named IntSet.java. This code shall be in the default package, and shall define a public class named IntSet that defines the following static methods, which have no side effects, and are specified by the equations below. Note that the add method is private; the other methods are public. public static IntSet emptySet (); public static IntSet singleton (int); public static IntSet adjoin (int, IntSet); public static boolean isEmpty (IntSet); public static int least (IntSet); public static IntSet butLeast (IntSet); public static int size (IntSet); public static IntSet union (IntSet, IntSet); private static IntSet add (int, IntSet); Algebraic specification: singleton (m) = adjoin (m, emptySet()) adjoin (m, emptySet()) = add (m, emptySet()) adjoin (m, add (n, s)) = add (m, add (n, s)) if m < n adjoin (m, add (n, s)) = add (n, s) if m = n adjoin (m, add (n, s)) = add (n, adjoin (m, s)) if m > n isEmpty (emptySet()) = true isEmpty (add (n, s)) = false least (add (n, s)) = n butLeast (add (n, s)) = s size (emptySet()) = 0 size (add (n, s)) = 1 + size (s) union (emptySet(), s) = s union (add (n, s1), s2) = adjoin (n, union (s1, s2)) Note: This specification does not define least and butLeast on an empty set. --------------------------------------------------