Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. We have provided an implementation of the Set ADT in Chapter 1. a) Implement a new version of the Set ADT using a sorted

1. We have provided an implementation of the Set ADT in Chapter 1.

a) Implement a new version of the Set ADT using a sorted linked list.

b) Evaluate your new implementations to determine the worst case run time of each operation.

c) Compare the run times of your new versions of the Set ADT to the one from Chapter 1.

Set ADT from chapter 1:

# Creates a new set from the union of this set and setB.

def union( self, setB ):

newSet = Set()

newSet._theElements.extend( self._theElements )

for element in setB :

if element not in self :

newSet._theElements.append( element )

return newSet

# Creates a new set from the intersection: self set and setB.

def interset( self, setB ): newSet = Set()

for element in setB :

if element in self :

newSet._theElements.append( element )

return newSet

# Creates a new set from the difference: self set and setB.

def difference( self, setB ): newSet = Set()

for element in self :

if element not in self :

newSet._theElements.append( element )

return newSet def properSubset( self, setB ): if self.isSubsetOf( setB ): if self.__eq__(setB): return False else: return True return False def __add__(self,setB): return self.union(setB) def __mul__(self,setB): return self.interset(setB) def __sub__(self,setB): return self.difference(setB) def __lt_(self,setB): return self.isSubsetOf(setB)

def _str(self): print(self._theElements)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Structure Of The Relational Database Model

Authors: Jan Paredaens ,Paul De Bra ,Marc Gyssens ,Dirk Van Gucht

1st Edition

3642699588, 978-3642699580

More Books

Students also viewed these Databases questions

Question

Are there any questions that you want to ask?

Answered: 1 week ago