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 7 elements 38 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 (9et , int * count, int elem); simply store elem in the array indexed by count then increment count int contains (Set =, 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 x is 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 resuit 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 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 symmetzicdifference (Set result,int *count, Set sl, 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 countl, Set s2, int count2) ; s1 is a subset of s2 if all elements of s1 are in s2 int disjoint (Set sl,int countl, Set s2, int count2); two sets are disjoint if the intersection is empty int equal (3et sl, int countl, Set -2, int count2); two sets are equal if they have exactly the same elements - Project name: SetArray Filenames: set.h, set.c, main.c
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 7 elements 38 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 (9et , int * count, int elem); simply store elem in the array indexed by count then increment count int contains (Set =, 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 x is 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 resuit 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 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 symmetzicdifference (Set result,int *count, Set sl, 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 countl, Set s2, int count2) ; s1 is a subset of s2 if all elements of s1 are in s2 int disjoint (Set sl,int countl, Set s2, int count2); two sets are disjoint if the intersection is empty int equal (3et sl, int countl, Set -2, int count2); two sets are equal if they have exactly the same elements - Project name: SetArray Filenames: set.h, set.c, main.c
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 11 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY