Question: Do in Python Language Instructions: All programs are to be written in Python. Functions must be documented with proper comments stating the purpose of the



Do in Python Language
Instructions: All programs are to be written in Python. Functions must be documented with proper comments stating the purpose of the function the types and meanings of the input arguments any conditions on the input arguments (input specifications) the type and meaning of the return values conditions on the outputs (output specifications) Within the program you MUST document the following: Representation invariant that your function maintains stated (at least infor- mally) as a comment, and a check that this is maintained. For example, if the input arguments are assumed to contain no duplicates, there should be no duplicates in the output. Loop invariant for each loop, even if informally stated, which give the intuition about why the program is correct. Highlight (via a comment) a decreasing measure in each while loop which guarantees termination of the loop. Time complexity of the function, with at least an informal justification. Representative test data on which you have run the function. Use appropriate notation in your arguments/explanations. You will get 0 for not writing appropriate explanations. You will be asked to explain these during the demo. In the first part of assignment you will develop a package for sets and their manipulation using operations such as union, intersection, Cartesian product etc. You have to implement a set S over elements of some type as a list that contains no duplicates. (Here the type T can variously be integer, floats, or even a list of some type). Implement the following functions for your implementation of sets. These func- tions represent the basic set operations. 1. A function emptyset(), which returns the representation of an empty set. 2. A boolean function isEmpty(S), returning True if S is empty and False otherwise. 3. A function member(S, e) where s is a set of elements of some type T which represented as a list and e is an element of that type. If e is a member of S, member should return True and otherwise should return False. 4. A function singleton(x), which returns the representation of a singleton set consisting of only the element x. 5. A function isSubset(P,Q), which given representations of two sets (of the same type) P and Q, returns True if P is a subset of Q and False otherwise. 6. A function setEqual(P,Q), which given representations of two sets of the same type) P and Q, returns True if P and Q have the same elements, and False otherwise. 7. A function union(P,Q), where P, Q are (representations of) two sets (of same type T), which returns the representation of the set PUQ. 8. A function intersection(P,Q) where P, Q are (representations of) two sets (of same type T), which returns the representation of the set PnQ. 9. A function cartesian(P,Q), where P, Q are (representations of) two sets (not necessarily of same type), which returns the representation of the set PXQ. 10. A function power(P), where P is (the representation of) some set, which returns the representation of the set of all subsets of P
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
