Question: 17. Python has a set type that efficiently implements mathematical sets. You can get information on this container class by consulting reference documents or typing
17. Python has a set type that efficiently implements mathematical sets. You can get information on this container class by consulting reference documents or typing help(set) at a Python prompt. Suppose you are implement-ing your own Set class that includes add, remove, clear, __contains__, intersection, union, and difference operations. Utilizing each of the following concrete data structures, explain how you would implement the required operations and provide an analysis of the run-time efficiency of each operation.
(a) an unordered Python list. (b) a sorted Python list.
(c) a Python dictionary. (Note: the elements of the set will be the keys, you can just use None or True as the value.)
Step by Step Solution
There are 3 Steps involved in it
To implement a custom Set class with the add remove clear contains intersection union and difference operations using different concrete data structures we need to consider the operations efficiency w... View full answer
Get step-by-step solutions from verified subject matter experts
