A set of integers 0..MAX may be implemented using an array of boolean values. This  particular implementation is called a bit-vector implementation of a Set. Since C doesn’t have  the Boolean data type, then substitute TRUE with 1 and FALSE with 0, or define 1 and 0 as  TRUE and FALSE, respectively. For example, if the integer 3 is an element of the set, then the array element indexed by 3 is  TRUE. On the other hand, if 3 is not an element, then the array element indexed by 3 is  FALSE. For example, if the integer 3 is an element of the set, then the array element indexed by 3 is  TRUE. On the other hand, if 3 is not an element, then the array element indexed by 3 is  FALSE. For example: if s = {3,4,6,8}, the array looks like this:   Implement a programmer-defined data type called BitSet to represent a set as follows: typedef int BitSet[MAX]; Implement the following functions: void initialize(BitSet s);  - set all array elements to FALSE void add(int elem,BitSet s); - set the item indexed by elem to TRUE void display(BitSet s); - display the set on the screen using set notation, e.g. {3,4,5,6} - this means that you will print the index value if the content of that cell is TRUE void getUnion(BitSet result,BitSet s1,BitSet s2);  - store in the array result the set resulting from the union of s1 and s2 - x is an element of s1 union s2 if x is an element of s1 or x is an element of s2 void intersection(BitSet result,BitSet s1,BitSet s2);  - store in the array result the set resulting from the intersection of s1 and s2 - x is an element of s1 intersection s2 if x is an element of s1 and x is an element of s2 void difference(BitSet result,BitSet s1,BitSet s2);  - store in the array result the set resulting from the difference of s1 and s2 - x is an element of s1 - s2 if x is an element of s1 and x is not an element of s2 int isEmpty(BitSet s); - the set is empty of all array elements are false int contains(BitSet s,int elem); - elem is an element of s if the array value indexed by elem is TRUE int disjoint(BitSet s1,BitSet s2);  - two sets are disjoint if the intersection is empty int equal(BitSet s1,BitSet s2); - two sets are equal if they have exactly the same elements int cardinality(BitSet s);  - the cardinality of the set is the number of TRUE elements int subset(BitSet s1,BitSet s2); - s1 is a subset of s2 if all elements of s1 are in s2

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

A set of integers 0..MAX may be implemented using an array of boolean values. This 
particular implementation is called a bit-vector implementation of a Set. Since C doesn’t have 
the Boolean data type, then substitute TRUE with 1 and FALSE with 0, or define 1 and 0 as 
TRUE and FALSE, respectively.
For example, if the integer 3 is an element of the set, then the array element indexed by 3 is 
TRUE. On the other hand, if 3 is not an element, then the array element indexed by 3 is 
FALSE.

For example, if the integer 3 is an element of the set, then the array element indexed by 3 is 
TRUE. On the other hand, if 3 is not an element, then the array element indexed by 3 is 
FALSE.
For example: if s = {3,4,6,8}, the array looks like this:

 

Implement a programmer-defined data type called BitSet to represent a set as follows:
typedef int BitSet[MAX];
Implement the following functions:
void initialize(BitSet s); 
- set all array elements to FALSE
void add(int elem,BitSet s);
- set the item indexed by elem to TRUE
void display(BitSet s);
- display the set on the screen using set notation, e.g. {3,4,5,6}
- this means that you will print the index value if the content of that cell is TRUE
void getUnion(BitSet result,BitSet s1,BitSet s2); 
- store in the array result the set resulting from the union of s1 and s2
- x is an element of s1 union s2 if x is an element of s1 or x is an element of s2
void intersection(BitSet result,BitSet s1,BitSet s2); 
- store in the array result the set resulting from the intersection of s1 and s2

- x is an element of s1 intersection s2 if x is an element of s1 and x is an element of s2
void difference(BitSet result,BitSet s1,BitSet s2); 
- store in the array result the set resulting from the difference of s1 and s2
- x is an element of s1 - s2 if x is an element of s1 and x is not an element of s2
int isEmpty(BitSet s);
- the set is empty of all array elements are false
int contains(BitSet s,int elem);
- elem is an element of s if the array value indexed by elem is TRUE
int disjoint(BitSet s1,BitSet s2); 
- two sets are disjoint if the intersection is empty
int equal(BitSet s1,BitSet s2);
- two sets are equal if they have exactly the same elements
int cardinality(BitSet s); 
- the cardinality of the set is the number of TRUE elements
int subset(BitSet s1,BitSet s2);
- s1 is a subset of s2 if all elements of s1 are in s2

H
PDF
C
2
BitSet using Arrays.pdf
of 2
File C:/Users/AMD/Downloads/BitSet%20using%20Arrays.pdf
Q
X +
Type here to search
Page view| A Read aloud |
DATO IT and amay rooun aTO DOLOouring mŪTTANTO ImorgoGOTT ON OT AND SE
void difference (BitSet result, BitSet s1, BitSet s2);
store in the array result the set resulting from the difference of s1 and s2
x is an element of s1 s2 if x is an element of s1 and x is not an element of s2
int isEmpty(BitSet s);
x is an element of s1 intersection s2 if x is an element of s1 and x is an element of s2
the set is empty of all array elements are false
int contains(BitSet s, int elem);
elem is an element of s if the array value indexed by elem is TRUE
int disjoint(BitSet s1, BitSet s2);
- two sets are disjoint if the intersection is empty
-
Add textDraw
int equal(BitSet s1, BitSet s2);
two sets are equal if they have exactly the same elements
int cardinality (BitSet s);
the cardinality of the set is the number of TRUE elements
int subset(BitSet s1, BitSet s2);
- s1 is a subset of s2 if all elements of s1 are in s2
DEV
+4
Highlight
{"
[+ Not syncing 1
Erase A 8
60
№.9
4) ENG
9:25 am
08/07/2022
...
LI
Transcribed Image Text:H PDF C 2 BitSet using Arrays.pdf of 2 File C:/Users/AMD/Downloads/BitSet%20using%20Arrays.pdf Q X + Type here to search Page view| A Read aloud | DATO IT and amay rooun aTO DOLOouring mŪTTANTO ImorgoGOTT ON OT AND SE void difference (BitSet result, BitSet s1, BitSet s2); store in the array result the set resulting from the difference of s1 and s2 x is an element of s1 s2 if x is an element of s1 and x is not an element of s2 int isEmpty(BitSet s); x is an element of s1 intersection s2 if x is an element of s1 and x is an element of s2 the set is empty of all array elements are false int contains(BitSet s, int elem); elem is an element of s if the array value indexed by elem is TRUE int disjoint(BitSet s1, BitSet s2); - two sets are disjoint if the intersection is empty - Add textDraw int equal(BitSet s1, BitSet s2); two sets are equal if they have exactly the same elements int cardinality (BitSet s); the cardinality of the set is the number of TRUE elements int subset(BitSet s1, BitSet s2); - s1 is a subset of s2 if all elements of s1 are in s2 DEV +4 Highlight {" [+ Not syncing 1 Erase A 8 60 №.9 4) ENG 9:25 am 08/07/2022 ... LI
11:3
H
PDF
C
1
BitSet using Arrays.pdf
File C:/Users/AMD/Downloads/BitSet%20using%20Arrays.pdf
+
of 2 Q
X +
Type here to search
CD Page view A Read aloud
A set of integers 0..MAX may be implemented using an array of boolean values. This
particular implementation is called a bit-vector implementation of a Set. Since C doesn't have
the Boolean data type, then substitute TRUE with 1 and FALSE with 0, or define 1 and 0 as
TRUE and FALSE, respectively.
-
For example, if the integer 3 is an element of the set, then the array element indexed by 3 is
TRUE. On the other hand, if 3 is not an element, then the array element indexed by 3 is
FALSE.
For example: if s = {3,4,6,8), the array looks like this:
0
1
2
3
4
5
6
7
8
9
FALSE FALSE FALSE TRUE TRUE FALSE TRUE FALSE TRUE FALSE
TAdd textDraw
Description
Implement a programmer-defined data type called BitSet to represent a set as follows:
typedef int BitSet[MAX];
Implement the following functions:
void initialize(BitSet s);
set all array elements to FALSE
void add(int elem, BitSet s);
set the item indexed by elem to TRUE
void display(BitSet s);
display the set on the screen using set notation, e.g. {3,4,5,6)
- this means that you will print the index value if the content of that cell is TRUE
void getUnion (BitSet result, BitSet s1, BitSet s2);
store in the array result the set resulting from the union of s1 and s2
- x is an element of s1 union s2 if x is an element of s1 or x is an element of s2
DEV
C+4
Highlight
void intersection (BitSet result, BitSet s1, BitSet s2);
store in the array result the set resulting from the intersection of s1 and s2
1²
[+ Not syncing 1
50
Erase A 8
№.9
4) ENG
9:24 am
08/07/2022
...
LI
Transcribed Image Text:11:3 H PDF C 1 BitSet using Arrays.pdf File C:/Users/AMD/Downloads/BitSet%20using%20Arrays.pdf + of 2 Q X + Type here to search CD Page view A Read aloud A set of integers 0..MAX may be implemented using an array of boolean values. This particular implementation is called a bit-vector implementation of a Set. Since C doesn't have the Boolean data type, then substitute TRUE with 1 and FALSE with 0, or define 1 and 0 as TRUE and FALSE, respectively. - For example, if the integer 3 is an element of the set, then the array element indexed by 3 is TRUE. On the other hand, if 3 is not an element, then the array element indexed by 3 is FALSE. For example: if s = {3,4,6,8), the array looks like this: 0 1 2 3 4 5 6 7 8 9 FALSE FALSE FALSE TRUE TRUE FALSE TRUE FALSE TRUE FALSE TAdd textDraw Description Implement a programmer-defined data type called BitSet to represent a set as follows: typedef int BitSet[MAX]; Implement the following functions: void initialize(BitSet s); set all array elements to FALSE void add(int elem, BitSet s); set the item indexed by elem to TRUE void display(BitSet s); display the set on the screen using set notation, e.g. {3,4,5,6) - this means that you will print the index value if the content of that cell is TRUE void getUnion (BitSet result, BitSet s1, BitSet s2); store in the array result the set resulting from the union of s1 and s2 - x is an element of s1 union s2 if x is an element of s1 or x is an element of s2 DEV C+4 Highlight void intersection (BitSet result, BitSet s1, BitSet s2); store in the array result the set resulting from the intersection of s1 and s2 1² [+ Not syncing 1 50 Erase A 8 №.9 4) ENG 9:24 am 08/07/2022 ... LI
Expert Solution
steps

Step by step

Solved in 4 steps with 7 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education