Write, by hand, a new member function for the Multiset ADT class given in the no
ID: 3652847 • Letter: W
Question
Write, by hand, a new member function for the Multiset ADT class given in the notes, that creates the intersection of two multisets. The intersection is the set of all elements that are common to two multisets. For example, if A = {1, 2, 2, 3, 7} and B = {2, 2, 7}, then the intersection of A and B, which is written as A ? B, is equal to A ? B = {2, 7}. Notice that although the element 2 occurs twice in each of A and B, it appears only once in A ? B. The prototype of the function that you are to write is given as void Multiset::GetIntersection(Multiset &thatSet;, Multiset &thisSet;_intersection_thatSet)Explanation / Answer
Below program me will help you in resolving .. #include #include #define SIZE 5 void get_data(int arr[]); void print_data(int arr[], int n); void bubble_sort(int arr[]); int find_intersection(int array_1[], int array_2[], int intersect_result[]); int find_union(int array_1[], int array_2[], int union_result[]); void main() { int array_1[SIZE], array_2[SIZE], intersect_result[SIZE], union_result[SIZE*2]; int num_elements; clrscr(); //Get the elements of Array1 printf(" Enter the elements of Array 1: "); get_data(array_1); printf(" Elements of Array 1: "); print_data(array_1, SIZE); //Sort array 1 bubble_sort(array_1); printf(" Sorted elements of Array 1: "); print_data(array_1, SIZE); //Get the elements of Array2 printf(" Enter the elements of Array 2: "); get_data(array_2); printf(" Elements of Array 2: "); print_data(array_2, SIZE); //Sort array 2 bubble_sort(array_2); printf(" Sorted elements of Array 2: "); print_data(array_2, SIZE); //Find Intersection and print the result num_elements = find_intersection(array_1, array_2, intersect_result); printf(" Intersection is: "); print_data(intersect_result, num_elements); //Find Union num_elements = find_union(array_1, array_2, union_result); printf(" Union is: "); print_data(union_result, num_elements); getch(); } void get_data(int arr[]) { int i,j; for(i=0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.