C Progamming Colorado Mountain College Set Implementation Questions

Fall 2023Set Implementation
Implement a program in C to perform set operations.
Set theory provides a foundational language underlying much of mathematics. For computer
science in particular, set theory can be used to describe programming language formal
grammars, state machines, and computing machines (such as the Turing Machine) and for other
semi-theoretical-ish uses. There are also practical applications of set theory in computer
science, such as calculating the value of Pi to some ridiculously precise value, or managing your
household pets. Sets are awesome!
Our Universe will consist of the following set of common household pets:
Universe = {Bat, Cat, Chimp, Dog, Fish, Liger, Snake, Turtle}
Requirements:
0) Convert a bit vector set representation into a set of strings (Done for you).
1) Insert a string into a bit vector set representation (Done for you).
2) Use bit operations (primarily) to implement the following operations on a bit vector set
representation:
a. Intersection
b. Union
c. Difference
d. Complement
e. IsASubset
f. IsAProperSubset
g. Calculate the set Cardinality
h. Print the power set
3) Given A = {Cat, Dog, Fish} and B = {Cat, Dog, Liger}, C = {Dog, Liger, Snake Turtle}. Perform
(at least) the following calculations:
a. (A U B) ∩ ~C
in C++: set D = Intersection(Union(A, B), ~C);
b. A U (B ∩ C)
c. ~(A ∩ B)
d. (~A U ~B)
e. A – B
f. PowerSet(A)
g. bool A ⊂ B
h. bool A ⊆ B
i. Create 2 more expressions of your own design and test them.
Page 1 of 3
4) Repeat the above operations for :
A = {Bat, Chimp, Liger, Snake, Turtle}
B = {Bat, Cat, Chimp, Dog, Fish}
C = {Dog, Fish, Liger, Snake Turtle}
5) Expand your program to work with a 32 bit universe as defined in the source code.
Repeat the above operations for :
A = { Bat, Dragon, Hippopotamus , Gecko, Sloth, Deer, Kangaroo}
B = { Hippopotamus , Gecko, Sloth, Bat, Rhinoceros, Squirrel, Platypus}
C = { Gecko, Sloth, Bat, Rhinoceros, Dog, Fish, Horse, Snake, Turtle, Donkey, Gorilla, Llama}
Resources:
Download the “sets.cpp” template from my website. Complete and test the functions declared
in the template.
Testing:
Thoroughly test with a variety of input values to demonstrate that your program works. Shown
below is minimal sample testing… you should do and submit proof of much more testing than
this.
1) Source Code.
2) Output
Sample Output
Set A: { Bat, Cat, Chimp, Snake }
Cardinality: 4
PowerSet(A):
{ }
{ Snake }
{ Chimp }
{ Chimp, Snake }
{ Cat }
{ Cat, Snake }
{ Cat, Chimp }
{ Cat, Chimp, Snake }
{ Bat }
{ Bat, Snake }
{ Bat, Chimp }
{ Bat, Chimp, Snake }
{ Bat, Cat }
{ Bat, Cat, Snake }
{ Bat, Cat, Chimp }
{ Bat, Cat, Chimp, Snake }
Set B: { Chimp, Fish, Liger }
Page 2 of 3
Set C: { Chimp, Fish, Liger }
(A Union B) Inter ~C: { Bat, Cat, Snake }
B is a subset of C
B is NOT a proper subset of C
and so forth…
Page 3 of 3

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper
Are you stuck with your online class?
Get help from our team of writers!

Order your essay today and save 20% with the discount code RAPID