Question: PYTHON PLEASE Question 1 [ 75 pts] : You are required to implement the class intSet for this question. Set is a special list (that

PYTHON PLEASE

Question 1 [ 75 pts] : You are required to implement the class intSet for this question. Set is a special list (that can be modeled using python list) in which each element appears only once, the order of elements is irrelevant. For sake of efficiency the cardinality of the set is stored as part of the set representation. The operations on set are as follows:

create Empty set of size zero, note it will be called __init__ in your implementation.

insert an element, adds a new int to a list and increases its size by one, however if an element is already present in the list then do not add it.

remove an element, removes the element from the list if it is present in the list.

isMember, checkers if an integer is member of the set

When a set is printed, we want all elements separated by commas and enclosed in braces { and }, note for this you will define the __str__ method properly.

isSubset checks that a set passed as parameter has all its elements present in the given set

Intersect takes another set as parameter and returns a new set such that all of the elements are present both in this set and the set passed as parameter.

Union takes another set as a parameter, and returns a new set such that all of the elements present in either of the original sets (self and other) are present in the returned set. Note, however, if an element appears in both sets it has only one copy in the new set.

Diff returns a new set composed of the difference of a given set from another set passed as a parameter is all the elements that are part of self but not present in the other set.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!