CPSC 170 Program 3: Sets

Introduction to Sets

A set is an unordered collection similar to the bag collection that we discussed in class. However, a set cannot contain duplicate elements, so if an item that is already in a set S is added to S, S does not change. Below are some common set operations:

Assignment

Write a SetADT interface for the collection described above, and a LinkedSet implementation of that ADT. Also write a test program that exercises your implementation. Your test program should allow the user to enter elements for two sets S1 and S2, then print each set, their union, their intersection, their difference (S1-S2), their cartesian product (S1xS2), and the powerset for each. It should also allow the user to repeatedly search for and then delete elements from S1. Be sure to label output and prompt for input nicely.

Some things to keep in mind: