Your assignment is to create the functions outlined below. In each case assume that we are using
Question:
Your assignment is to create the functions outlined below. In each case assume that we are using the Python's list data container to represent sets. You are welcome to use any function you created to solve a subsequent problem.
A. Create a function called noRepeats whose input is a set (list) A that may or may not have repeated elements, and whose output is a list that represents the same set as A but has no repeated elements. For instance, if [a, b, c, a. c, d] is the input, then the output is [a, b, c, d].
B. Create a function called cardinality" whose input is a set (list) A that may or may not have repeated elements, and whose output is the number of elements in the set.
C. Create a function called "intersect" whose inputs are two sets (lists) A and B. and whose output is a set (list) that is the intersection An B of the two sets.
D. Create a function called "union" whose inputs are two sets (lists) A and B, and whose output is a set (list) that is the union AUB of the two sets.
E. Create a function called complement whose inputs are two sets (lists) A and U (think of U as the universe) with ACU, and whose output is .
F. Create a function called "cartesianProduct" whose inputs are two sets (lists) A and B, and whose output is a set (list) that is the Cartesian product Ax B of the two sets. Note that ordered pairs may be represented by lists with two components.
G. Create a function called "powerSet" whose input is a set (list) A. and whose output is a set (list) whose entries are lists representing the subsets of A.
Modern Database Management
ISBN: 978-0133544619
12th edition
Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi