Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 6 Due Date: See Blackboard Source File: /2336/06/lab06. (CICPPlcpple Ieelexxep) Input: Output: Value: Under control of main function Under control of main function Extend

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Lab 6 Due Date: See Blackboard Source File: /2336/06/lab06. (CICPPlcpple Ieelexxep) Input: Output: Value: Under control of main function Under control of main function Extend the IntegerSet class from Lab 04 to provide the following additional member functions: The union of sets A and B is the set of all elements that are in A or in B or in both A and B .The intersection of sets A and B is the set of all elements that are in both A and B .The difference of sets A and B is the set of all elements in A that are not in B . The symmetric difference of two sets is the union of two sets minus the intersection. A header file is shown in Figure 1. a sample main function for testing your implementation is shown in Figure 2, and a sample execution sequence is shown in Figure 3. To use the Makefile as distributed in class, add a target of labo6 to targets2erefileswithlibrary #ifadef #define LAB06-H LAB06-H a #include #include bit8.h> using nanespace std const uint N- 0 class IntegerSet ic: IntegerSet // initializes the set to the enpty /I set uIntegerSet (const IntegerSet& otherSet): II copy constructor // destructor // returns true if e is a member of / the set and false othervise /I cardinality of a set / if e is valid and not a member of / the set, insert e into set / if e is valid and a menber of / the set, delete e from set II complement of a Set IntegerSet O bool isMember (uint e) const; uint cardinalityO const; Void insertElement (uint e) void deleteElement (uint e) IntegerSet complement O const; ostrean& print (ostreamk os) const; IntegerSet Union (const IntegerSet& otherSet) const; IntegerSet intersection (const IntegerSet& otherSet) const; IntegerSet difference (const IntegerSet& otherSet) const; a IntegerSet symmetricDifference(const IntegerSet& otherSet) const; Figure 1. /uer/local/2336/include/lab06.h (Part 1 of 2) Lab 6 Due Date: See Blackboard private: /I Pointer to dynanically II allocated memory aa uint +bitvector as bool isValid (uint e) const a int word (uint n) const // Determine index vithin / bitVector where n is located // Determine position vithin /I bitVector [word (n)] / for elenent n // Calculate # of elements // in bitVector to represent / elements 0.. (N-1) & then II allocate storage int bit(uint n) const; void allocatetorageO #endif Figure 1. /usr/local/2336/include/lab06.h (Part 2 of 2) # include #include a using nanespace std; int mainO uint e, j. n IntegerSet s,t; hile (cin >>n) for (j-0; j n: for 0; j e t.insertElement (e) Figure 2. /usr/local/2336/src/lab06main.C (Part 1 of 2) Page 2 CS 2336Data Structures and Algorithms Lab 6 Due Date: See Blackboard cout -/getlab.ksh 06 Checking to see if a folder exists for Lab 06. - .No Creating a folder for Lab 06 Checking to see if Lab 06 has sanple input and output files. Yes Copying input and output files for Lab 06 fron folder usr/local/2336/data/06 to folder /06 Checking to see if /usr/local/2336/src/lab08main.C erists. .Yes Copying file usr/local/2336/src/lab08main.C to folder ./06 Checking to see if /usr/local/2336/include/lab06.h exists. Yes Copying file usr/local/2336/include/lab06.h to folder ./06 Copying file usr/local/2336/src/Makefile to folder -/08 Adding a target of lab06 to targets2srcfilesvithlibrary Touching file -/08/lab06.cpP Edit file ./06/1ab06.cpp in Notepad++ nevuserdcsunix /2336> ed 06 T nenaser csuni /2338/06> 15 s 01.dat 01.out Makefile lab06.cpp lab06.h labO6nan.c nevuseracsunix /2336/06>make lab08 -8 -Wall -std-c -c lab08main.C-I/usr/local/2336/include -I. g++-g-vai -std- ++ 11 -c 1ab06.cpp-1/usr/local/2336/include -I. glab06 lab06main.o labo6.0 -L/usr/local/2336/1ib W-vhole-archive -1lab08-V -no-whole-archiveln-1bits nevusercuniz/2336/06> cat 01.dat 1234 145 1 24 8 16 32 ai 10 36912 15 3 6 9 12 15 13 as 48 12 16 20 24 28 32 36 40 44 48 52 s 48 01 23456 7 89 10 11 12 13 14 15 16 17 18 19 as 20 21 22 23 24 25 26 27 28 29 as 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 Figure 3. Commands to Compile, Link, & Run Lab 06 (Part 1 of 2) CS 2336Data Structures and Algorithms a nevuserQcsuni /2336/06> cat 01.dat I /lab06 S1,2.3.4) s.cardinality4 t-11.4.5 t.cardinality3 1,2.3.4.5) 1,4) s d (2,3) sd12,3.5 a1,2.4,8.18,32) s.cardinality6 ss t13,6.9,12,15 t.cardinality 1,2.3.4.6,8,9,12.15,16,32 d1,2.4,8.18,32) o sd1,2.3.4.6,8,9,12.15,16,32 4,8.12,16,20,24,28,32,36 s.cardinality9 6t0,1.2,3.4,5.6,7.8,9,10,11,12,13,14,15,16,17.18,19.20,21,22,23,24,25,26,27.28.29,30,31,32.33,34,35,38,37.38,39 t.cardinality40 60,1.2,3.4,5.6,7.8,9,10,11,12,13,14,15,16,17.18,19.20,21,22,23,24,25,26,27.28.29,30,31,32.33,34,35,38,37.38,39 i4,8.12,16,20,24,28,32,36 ed-(0, 1,2,3,5,6,7,9,10, 11, 13,14, 15, 17, 18, 19,21,22,23,25,26,27,29,30,31,33 ,34,35,37,38,3 6 s.cardinality0 t.cardinality0 o nevuser csunix /2338/06> cat 01.datI/habo8 ny.out nevuser csunix /2338/06> diff 01.out ny.out nevuser csunix /2336/06> Figure 3. Commands to Compile, Link, & Run Lab 06 (Part 2 of 2) #include1ab06.h> IntegerSet Intergetset: :Union (const IntegerSet& otherSet) const Intergetset myUnion; //declare a local IntegerSet object //IntegerSet myUnion( this);//ok //IntegerSet myUnion-*this;/ot ok //populate the local IntegerSet for( uint e-0; exN; ett) if (this->isMember(e) l otherSet.isMember(e)) myUnion.insertElement(e); return myUnion;//return the local Intergetset object IntegerSet Intergetset::intersection (const IntegerSet& otherSet) const; IntegerSet Intergetset::difference (const IntegerSet& otherSet) const; IntegerSet Intergetset: :symmetricDifference(const IntegerSet& otherSet) const<>

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

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions