# In this Program Set ADT has been implemented using Python
class UnfairSet :
# Following function is used to create an empty set using list
def __init__( self, *char ): # Create a self instances
self._theElements = list() # Define the list
for i in range(len(char)) : # Ranges out the list
self._theElements.add( char ) # Create new element in the Set

# This function is used to find the size of the Set.
def __len__( self ): #Function called len to find the size of list
return len( self._theElements )

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!

order now

# This function compare element in the set
def __contains__( self, char ):
return char in self._theElements

# This function is used to find the empty set
def isEmpty( self ):
return len(self._theElements) == 0

# This function is used add in elements.
def add( self, char ):
if char not in self :
self._theElements.append( char )
print(‘Element in the set after addign a character:’)

# This function is used to remove elements
def remove( self, char ):
assert char in self, “The element must be in the set.”
self._theElements.remove( char )
print(‘Element in the set after deleting a character:’)
#This is the Unfairset
m.add(‘a’) #This is to add a in the set
print (‘Size of the setafter adding a is: %d’ %a) #This will show the new list size
print (‘Size of list after adding c is : %d’ %b) #This print the list size 1
m.remove(‘c’) #This allows the remove a set
print (‘Size of the set after deleting c: %d’ %c)

m.add(‘a’) #This is the set function
print (‘Size of the list after adding a which exist in the list is: %d’ %d) #This will print the list size of 1 as a is already in list it will not be added

#Stacckoverflow. 2018. Unfairset. ONLINE Available at: https://stackoverflow.com/questions/51069217/algorithms-programming-adt. Accessed 13 June 2018.


I'm James!

Would you like to get a custom essay? How about receiving a customized one?

Check it out