[Solved]Write C Program Include Library Q37251221
Write a C++ program.
Do not include any library other than <iostream>,<iomanip>, <fstream> and or <cmath>



Q3. Pointer Let’s consider a new method called linked list to store data rather than using array in this question. We start by declaring a new class called node. It has two members, which are an int called data used to store the current number, and a pointer called next used to direct to the next number. There is an extra node pointer called head points to the first node object for accessing data. The next pointer of the last node points to NULL indicating the end of the list. head 4 6 Null The diagram demonstrates how the above method stores a sequence of number 4, 5, 1, 2, 6 head is used to access the list after storage. It points to the first node and is returned to the user. Each node consists of int data to store the number and pointer next to points to the next node. The pointer of the last node points to NULL indicating the end of the list. Let’s consider two linked list in which integers are stored in ascending order. Now implement a method to merge this two ordered linked lists and keep the integers in ascending order as well. For example, given two ordered linked lists whose elements are 1, 3, 6, 7 and 2, 4, 8, 9 respectively. The elements of merged linked list should be 1, 2, 3, 4, 6,7, 8,9. Note: 1. Your program should prompt the user to input two integers indicating the numbers of elements of the two linked lists. We assume the integers are all positive integers and the input of users are valid. Then your program should prompt the user to input the elements of the first and second linked lists Assume all the input numbers are positive and less than ten, and the input numbers of every linked list is in ascending order. 2. 3. The suggested structure of node is showed below class node ( public: int data node* next; Expected Outcomes Example 1 Please input the count of the numbers: 5 4 Please input the content of the numbers of first linked list: 1 3479 Please input the content of the numbers of second linked list: 245 6 The merged linked list is: 1 2 3 4 4 5 679 Example 2 Please input the count of the numbers: 5 5 Please input the content of the numbers of first linked list: 2789 10 Please input the content of the numbers of second 1inked list 3 4 5 6 11 The merged linked list is: 23 4 5 67 8 9 10 11 Show transcribed image text Q3. Pointer Let’s consider a new method called linked list to store data rather than using array in this question. We start by declaring a new class called node. It has two members, which are an int called data used to store the current number, and a pointer called next used to direct to the next number. There is an extra node pointer called head points to the first node object for accessing data. The next pointer of the last node points to NULL indicating the end of the list. head 4 6 Null The diagram demonstrates how the above method stores a sequence of number 4, 5, 1, 2, 6 head is used to access the list after storage. It points to the first node and is returned to the user. Each node consists of int data to store the number and pointer next to points to the next node. The pointer of the last node points to NULL indicating the end of the list. Let’s consider two linked list in which integers are stored in ascending order. Now implement a method to merge this two ordered linked lists and keep the integers in ascending order as well. For example, given two ordered linked lists whose elements are 1, 3, 6, 7 and 2, 4, 8, 9 respectively. The elements of merged linked list should be 1, 2, 3, 4, 6,7, 8,9. Note: 1. Your program should prompt the user to input two integers indicating the numbers of elements of the two linked lists. We assume the integers are all positive integers and the input of users are valid. Then your program should prompt the user to input the elements of the first and second linked lists Assume all the input numbers are positive and less than ten, and the input numbers of every linked list is in ascending order. 2. 3. The suggested structure of node is showed below class node ( public: int data node* next;
Expected Outcomes Example 1 Please input the count of the numbers: 5 4 Please input the content of the numbers of first linked list: 1 3479 Please input the content of the numbers of second linked list: 245 6 The merged linked list is: 1 2 3 4 4 5 679
Example 2 Please input the count of the numbers: 5 5 Please input the content of the numbers of first linked list: 2789 10 Please input the content of the numbers of second 1inked list 3 4 5 6 11 The merged linked list is: 23 4 5 67 8 9 10 11
Expert Answer
Answer to Write a C++ program. Do not include any library other than , , and or … . . .
OR

