Chapter 11: Problem 19
Create and test a Set class to represent a classical set. Your sets should support the following methods: Set (elements) Creates a set (elements is the initial list of items in the set \()\) addElement \((x)\) Adds \(x\) to the set. deleteElement \((\mathrm{x})\) Removes \(\mathrm{x}\) from the set, if present. If \(\mathrm{x}\) is not in the set, the set is left unchanged. member \((\mathrm{x})\) Returns true if \(\mathrm{x}\) is in the set and false otherwise. intersection(set2) Returns a new set containing just those elements that are common to this set and set2. union(set2) Returns a new set containing all of elements that are in this set, set2, or both. subtract (set2) Returns a new set containing all the elements of this set that are not in set2. By the way, sets are so useful that Python actually has a built-in set datatype. While you may want to investigate Python's set, you should not use it here. The point of this exercise is to help you develop your skills in algorithm development using lists and dictionaries.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.