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 3 and 12. Left circle P has 2 and 8, right circle Q has 7,11, and 25
bottom left is outside is 1 and 10 and outside on the right is 16)//
From the figure, one finds that:
The universal set is:
U ={1,2,3,7,8,10,11,12,15,16}
Set P ={2,3,8,12), and
Set Q ={3,7,11,12,15}
Hence, the union of and is given by:
R = P union Q ={2,3,7,8,11,12,15}
From the diagram, there are three elements, {1,10 and 16}, 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: (1) item that stores the integer value in the set and (2) 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 (i.e., 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:
1. The sets P and Q shown in the Venn diagram above.
2. Assume set P has the elements 5,3,7,10,9(entered by the user in any order) and set Q has the elements 8,2,5,3,9,1,0(also entered by the user in any order). The program should output the three sets sorted as follows
P ={3,5,7,9,10},5 elements
Q ={0,1,2,3,5,8,9}7 elements
R = P union Q ={0,1,2,3,5,7,8,9,10}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!