Implement a generic Bag class (see Programming Exercise 3.11). Exercise 3.11 Implement a Bag class. A bag
Question:
Implement a generic Bag class (see Programming Exercise 3.11).
Exercise 3.11
Implement a Bag class. A bag is like a set except that a bag may have duplicates. For this exercise, the bags elements should be ints. The public interface should support the counterpart operations given in Programming Exercise 3.9. 3.
Implement a Set class, where a set is an unordered collection of none or more elements with no duplicates. For this exercise, the elements should be ints. The public interface consists of methods to
Create a Set.
Add a new element to a Set.
Remove an element from a Set.
Enumerate the elements in the Set.
Compute the intersection of two Sets SI and S2, that is, the set of elements that belong both to SI and to S2.
Compute the union of two Sets SI and S2, that is, the set of elements that belong to SI or to S2 or to both.
Compute the difference of two Sets SI and S2, that is, the set of elements that belong to SI but not to S2.