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 to extend 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...

Answer the following statements true (T) or false (F)

1) The finally block is executed only if no error was reached in the try block. 2) Resource de-allocation should be done explicitly in the finally block. 3) There can be no code in between try/catch/finally blocks. 4) The Message property of an exception is what is displayed to the user should that exception be thrown. 5) Stack unwinding is the process that attempts to locate an appropriate catch handler for an uncaught exception.

Computer Science & Information Technology

COGNITIVE ASSESSMENT When you use a credit card to purchase an item, what are you interacting with?

A. a TPS B. a CMS C. an EFT D. an MMS

Computer Science & Information Technology