A set of integers may be implemented using an array of integers. Since the array is only partially filled, it is important to store the number of elements contained in the array. The program contains the array itself and another integer to store the actual number of elements in the set. To illustrate, given a set s= (3, 8, 15, 20} O 1 2 3 4 6 elements 15 20 count Implement the following functions given the definition: typedef int Set [MAX); //Set is just an alias for int (MAX) //Set means an array of integers void initiaiise (int *count); - simply set count to o void display (Set , int count); display on the screen all valid elements of the array, from 0.count-1 void add (Set s, int *count, int elem); simply store elem in the array indexed by count then increment count int contains (Set s, int count, int elem); search the array elements for the value elem void get Union (Set result, int *count, Set sl, int countl, count2) ; - store in the array result the set resulting from the union of s1 and s2 Set 2, int - xis an element of s1 union s2 if x is an element of s1 or x is an element of s2 void intersection (Set result, int *count, Set sl, int countl, Set s2, int count2); - store in the array result the set resulting from the intersection of s1 and s2 xis an element of s1 intersection s2 if x is an element of s1 and x is an element of s2 void difference (Set result, int *count, Set s1, int countl, Set s2, int count2); store in the array result the set resulting from the difference of s1 and s2 xis an element of s1 - s2 if x is an element of s1 and x is not an element of s2 void symmetziedifference (Bet result, int *count, Set s1, int countl, Set s2, int count2); store in the array result the set resulting from the symmetric 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 and vice versa int subset (Set sl,int counel, Set s2, int count2); - si is a subset of s2 if all elements of s1 are in s2 int disjoins (Set sl, int countl, Set s2, int count2); two sets are disjoint if the intersection is empty int equal (Set sl, int countl, Set s2, int count2); two sets are equal if they have exactly the same elements Project name: SetArray Filenames: set.h, set.c, main.c

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 23PE
icon
Related questions
Question
100%

C Programming - Arrays

Hello, can anyone help me code this? I am struggling...

A set of integers may be implemented using an array of integers. Since the array is only partially filled,
it is important to store the number of elements contained in the array. The program contains the array
itself and another integer to store the actual number of elements in the set.
To illustrate, given a set s= {3, 8, 15, 20}
1
2
3
4
5
6
elements
15
20
count
4
Implement the following functions given the definition:
typedef int Set (MAX);
//Set is just an alias for int [MAX)
//Set means an array of integerS
void initialise (int*count);
simply set count to o
void display (Set s, int count);
-
display on the screen all valid elements of the array, from 0.count-1
-
void add (Set s, int * count, int elem);
simply store elem in the array indexed by count then increment count
int contains (Set s, int count, int elem);
search the array elements for the value elem
-
void getUnion (Set result, int *count, Set sl, int countl,
Set s2, int
count2);
store in the array result the set resulting from the union of s1 and s2
- xis an element of s1 union s2 if x is an element of s1 or x is an element of s2
void intersection (Set result, int *count, Set s1, int countl, Set s2, int
count2);
- 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 (Set result, int *count, Set sl,int countl, Set s2, int
count2);
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
void symmetricdifference (Set result, int *count, Set sl,int countl, Set
52, int count2);
store in the array result the set resulting from the symmetric 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 and vice versa
int subset (Set sl, int countl, Set s2, int count2) ;
si is a subset of s2 if all elements of s1 are in s2
int disjoint (Set s1,int countl, Set s2, int count2);
two sets are disjoint if the intersection is empty
int equal (Set sl, int countl, Set s2, int count2);
two sets are equal if they have exactly the same elements
-
Project name: SetArray
Filenames: set.h, set.c, main.c
00
Transcribed Image Text:A set of integers may be implemented using an array of integers. Since the array is only partially filled, it is important to store the number of elements contained in the array. The program contains the array itself and another integer to store the actual number of elements in the set. To illustrate, given a set s= {3, 8, 15, 20} 1 2 3 4 5 6 elements 15 20 count 4 Implement the following functions given the definition: typedef int Set (MAX); //Set is just an alias for int [MAX) //Set means an array of integerS void initialise (int*count); simply set count to o void display (Set s, int count); - display on the screen all valid elements of the array, from 0.count-1 - void add (Set s, int * count, int elem); simply store elem in the array indexed by count then increment count int contains (Set s, int count, int elem); search the array elements for the value elem - void getUnion (Set result, int *count, Set sl, int countl, Set s2, int count2); store in the array result the set resulting from the union of s1 and s2 - xis an element of s1 union s2 if x is an element of s1 or x is an element of s2 void intersection (Set result, int *count, Set s1, int countl, Set s2, int count2); - 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 (Set result, int *count, Set sl,int countl, Set s2, int count2); 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 void symmetricdifference (Set result, int *count, Set sl,int countl, Set 52, int count2); store in the array result the set resulting from the symmetric 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 and vice versa int subset (Set sl, int countl, Set s2, int count2) ; si is a subset of s2 if all elements of s1 are in s2 int disjoint (Set s1,int countl, Set s2, int count2); two sets are disjoint if the intersection is empty int equal (Set sl, int countl, Set s2, int count2); two sets are equal if they have exactly the same elements - Project name: SetArray Filenames: set.h, set.c, main.c 00
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning