/Sset-and-Uset-Implementation

Implementation of Data Structures Sset and Uset with an Exercise combining both

Primary LanguagePython

Uset and Sset Implementation code in Python

Sset and Uset

There are two files namely sset.py and uset.py which contain the implementation of both data structures in python. There are also test files for you to check if your code is working correctly.

Bag Implementation

In order to furthur our understanding of the two given data structures I have performed a question from Open Data Structures by Pat Morin. This will give us a better idea of how these data structures can be used. The following is Exercise 1.5

Exercise 1.5. Using a USet, implement a Bag. A Bag is like a USet—it supports the add(x), remove(x) and find(x) methods—but it allows duplicate elements to be stored. The find(x) operation in a Bag returns some element (if any) that is equal to x. In addition, a Bag supports the find all(x) operation that returns a list of all elements in the Bag that are equal to x.