Completing implementation of iterator for Practical-A4.py #2
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
'''
Problem Statement: To create ADT that implement the "set" concept.
a. Add (newElement) -Place a value into the set
b. Remove (element) Remove the value
c. Contains (element) Return true if element is in collection
d. Size () Return number of values in collection Iterator () Return an iterator used to loop over collection
e. Intersection of two sets
f. Union of two sets
g. Difference between two sets
h. Subset
Code from Data Structures and Algorithms (SPPU - Second Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-se-comp-content/DataStructuresAndAlgorithms/
'''
BEGINNING OF CODE
setOne=[]
setTwo=[]
def addVal(Set):
Function to add value to set
def delVal(Set):
Function to delete value from set
def searchVal(Set):
Function to search value in set
def size(Set):
Function to print size (length) of set
def intersection(setA, setB):
Function to perform intersection of two sets
def iterator(set1):
a=iter(set1)
for i in range(0,len(set1)-1):
print(next(a),"->",end=' ')
print(next(a))
def union(setA, setB):
Function to perform union of two sets
def difference(setA, setB):
Function to perform difference of two sets
def subsetCheck(setA, setB):
Function to check if two sets are subsets, called in subset()
def subset(setA, setB):
Function to print if two sets are subsets
def main():
Function for main menu
main() # Calling the main function
END OF CODE
Added iterator.