All #\'s unsigned. You are to write a program (in Java) to computethe intersecti
ID: 3617055 • Letter: A
Question
All #'s unsigned. You are to write a program (in Java) to computethe intersection and union of two sets A and B. The Universeset has 128 elements numbered from 1 to 128. That is U = {1,2, 3, 4,…, 128}. Your program must use NO more than 16memory locations to represent four sets A, B, C, and D. Theelements of each set are represented in bitformat. An elementin a set is marked by a 1. The missing elements are marked by a0.
For example, unsigned a[0] = 0x80010001, a[1] = 0x80010001, a[2] = 0x80010001, a[3] = 0x80010001;
defines the elements of set A inbit-format. The elements are numbered from left to right. For example, bit-pattern of a[0]indicates that elements 1, 16, and 32 are in set A, bit-pattern ofa[1] indicate that elements 33, 48, and64 are also in set A, and so on.
Do thefollowing: 1) Determine the elements of C = A B in bit-format. Hint: Use the bit-wise AND operator (&). Print set C inbit-format.
( | ). Print set D inbit-format.
3) Convert the bit-format of sets Cand D to the list of actual elements. Specifically, write a function and call it twice oncepassing set C and second time passing set D. This function converts the bit-pattern toa list of actual elements. A sample output for set A is given below.
Explanation / Answer
please rate - thanks as per your message in C++ to get you started #include #include using namespace std; void input(unsigned int[]); void print(unsigned int[],string); void unyon(unsigned int[],unsigned int[],unsigned int[]); void intersect(unsigned int[],unsigned int[],unsigned int[]); int main() {unsigned int a[4]={0},b[4]={0},c[4]={0},d[4]={0}; int i,j; input(a); //print (a,"a"); input(b); //print(b,"b"); unyon(a,b,c); intersect(a,b,d); print (a,"a"); print(b,"b"); print(c,"c"); print(d,"d"); system("pause"); return 0; } void input (unsigned int a[] ) {int i,word,bit; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.