Write a new container class called ser which is similar to


Question: A bag can contain more than one copy of an item. For example, the chapter describes a bag that contains the number 4 and two copies of the number 8. This bag behavior is different from a set, which can contain only a single copy of any given item.

Write a new container class called ser, which is similar to a bag, except that a set can contain only one copy of any given item, You will need to change the interface a bit. For example, instead of the bag's count function, you'll want a constant member function such as this:

bool set:: contains

(const value_type& target) const;

//Postcondition: The return balue is true if target is in the set; otherwise the return value is false.

Make an explicit statement of the invariant of the set class. Do a time analysis for each operation. At this point, an efficient implementation is not needed. For example, just adding a new item to a set will take linear time because you will need to check that the new item isn't already present, later we'll explore more efficient implementations (adding the implementation of set in the C++ Standard Library.

You may also want to add additional operations to your set class, such as an operator for subtraction.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Write a new container class called ser which is similar to
Reference No:- TGS0952063

Expected delivery within 24 Hours