Write a complete generic program that implements the adt


Assignment
Write a complete generic program that implements the ADT Bag using a singly-linked list. A Bag is just a container for a collection of items (analogy: a bag of candy) with the following behaviors:

- The positions of data items do not matter. For instance, {3, 2, 10, 6} is equivalent to {2, 3, 6, 10}
- There can be duplicate items (e.g., {7, 2, 10, 7, 5})

Your program does not need to write the main() method, but must implement the ADT

Bag class with the following definitions/methods:

• class definitions, constructor, and help methods
• add(item): add item to the Bag (you may insert it at the front/tail - the order of insertions does not matter).
• remove(item): remove one occurrence of item (if any) from the Bag
• contains(item): check if item is in the Bag
• grab(): get an item at random, without removing it, which reflects the fact that the items don't have a position (and thus we can't say "get the 5th item in the Bag")
• size(): return the number of elements in the Bag
• isEmpty0: indicate whether no items are stored in the Bag.

Solution Preview :

Prepared by a verified Expert
Programming Languages: Write a complete generic program that implements the adt
Reference No:- TGS02288585

Now Priced at $50 (50% Discount)

Recommended (93%)

Rated (4.5/5)