Question: * * * FLOW CHART ONLY PLEASE * * * * In this assignment, you are going to develop a C PROGRAMMING program that computes
FLOW CHART ONLY PLEASE
In this assignment, you are going to develop a C PROGRAMMING program that computes the union of two sets of integer values. Recall that the union of two sets is the set of elements that belong to either one or both sets.
To refresh your memory, the Venn diagram in the figure below depicts the union of two sets P and Q
Venn diagram: two circles whos shared part has and Left circle P has and right circle Q has and
bottom left is outside is and and outside on the right is
From the figure, one finds that:
The universal set is:
U
Set P and
Set Q
Hence, the union of and is given by:
R P union Q
From the diagram, there are three elements, and that dont belong to either of the two sets. Your program shall prompt the user to enter the number of distinct elements in the first set, followed by the values of its elements entered by the user in an arbitrary order Then, the program does the same for the second set, Q After the members of the two sets have been read the program computes the union of the two sets and prints it Your implementation shall make use of singly linked lists to store the sets P Q and their union, R The three linked list are to be kept SORTED all the time.
A description of what the program shall do follows:
It declares a struct to store the integer value in each node of a linked list. A node has to have at least two fields: item that stores the integer value in the set and next that stores the address of the successor node in the set. If you dont like the identifiers item and next you can use data and link or whatever you feel comfortable with!
It declares three linked lists that are initially empty. You may use the identifiers P Q and R as identifiers for the heads of the three lists The program prompts the user for the number of elements in set say, n followed by integer values that are members of the set. Each value is inserted in the linked list of P while keeping it sorted Similarly, the user is prompted for the number of elements in set say, m followed by integer values that are inserted in the linked list of Q
while keeping it sorted
The program traverses the linked list one node at a time and inserts a new node in the linked list that stores the same value of the node in
The program repeats the previous step for the elements in the linked list and inserts them in the linked list one at a time while: Keeping the set R sorted, and Avoiding inserting the same value twice in if the element belongs to both P and Q
Finally, the program displays the thee linked list P Q R They should appear sorted because they were kept sorted at all times.
Since your program is going to output the three sets P Q and R you want to have a function that receives a pointer to the first node of a linked list ie the head as an input parameter, traverses the list and prints the value stored in each node.
To test your program consider the following cases:
The sets P and Q shown in the Venn diagram above.
Assume set P has the elements entered by the user in any order and set Q has the elements also entered by the user in any order The program should output the three sets sorted as follows
P elements
Q elements
R P union Q
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
