Assignment 1.1: ADT Bag

Original price was: $35.00.Current price is: $30.00.

Rate this product

CISC-235 Data Structures
Assignment 1.1
1 Problem Context: ADT Bag
In class, we defined an Abstract Data Type called “Bag”. A bag is a container
for a group of data items. It has two main features:
1) The positions of the data items don’t matter.
2) The items do not need to be unique (unlike a set).
The Bag ADT also defines six operations applied on the data stored in the
1) add(item): add item to the Bag
2) remove(item): remove one occurrence of item (if any) from the Bag.
3) contains(item): check if item is in the Bag.
4) numItem s(): get the number of items in the Bag
5) grab(): get an item at random, without removing it.
6) str (): get a string representing the current contents of the bag.
2 Assignment Requirements
Your assignment is to create a class in Python/Java/C++ to implement the details of the six operations defined in Section 1 and write a test to demostrate the
correctness of your function. For instance, to demostrate that your add(item)
is correct, you need to print the data items in the bag before and after running
this function. You are only allowed to use the build-in libraries and modules provided by Python/Java/C++. Your test code should be put in a main
If you are writing Python code, you must put your test code inside a main
def main():
[your test code]
if __name__== ’__main__’:
Deadline: By the end of next Wednesday (Jan-16,2019)
Where to submit: OnQ
What to submit: You should upload your runnable source code (one file containing Bag ADT implementation and test code). I don’t need extra document
as we are not doing any algorithm analysis for this task.


There are no reviews yet.

Be the first to review “Assignment 1.1: ADT Bag”

Your email address will not be published. Required fields are marked *

Scroll to Top