A bag is a very similar construct to a set except that duplicates are allowed in a bag. What changes would have to be made toextend a TreeSet to create an implementation of a bag?
What will be an ideal response?
The primary change would be to remove the duplicate restriction in the add method. Since the addAll method, and then indirectly the union method, use the add method, this one change will allow duplicates. The definitions of other methods would need to be examined as well. For example, should the remove method delete the first occurrence of an element or all occurences of an element?
Computer Science & Information Technology
You might also like to view...
When showing changes, which of the following is NOT displayed in a Screen Tip?
A) Your name B) Date of change C) Your initials D) Time of change
Computer Science & Information Technology
The results of PricePerRoom: [ListPrice]/([Beds]+[Baths]+3 ) will appear in a column with the heading ________
A) PricePerRoom B) Beds C) ListPrice D) Baths
Computer Science & Information Technology