3. Assume that the node of a linked list is in the usual info-link form with the info of type int. The
following data, as described in parts (a) to (d), is to be inserted into an initially linked list: 72, 43,
8, 12. Suppose that head is a pointer of type nodeType. After the linked list is created, head
should point to the first node of the list. Declare additional variables as you need them. Write
the C++ code to create the linked list. After the linked list is created, write a code to print the
list. What is the output of your code?
a. Insert 72 into an empty linked list.
b. Insert 43 before 72.
c. Insert 8 at the end of the list.
d. Insert 12 after 43.
4. Assume that the node of a linked list is in the usual info-link form with the info of type int. (list
and ptr are pointers of type nodeType.) The following code creates a linked list:
ptr = new nodeType;
ptr -> info = 16;
list = new nodeType;
list - > info = 25;
list -> link = ptr;
ptr = new nodeType;
ptr -> info = 12;
ptr -> link = NULL;
list ->link -> link = ptr;
Use the linked list created by this code to answer the following questions. (These questions are
independent of each other.) Declare additional pointers if you need them.
a. Which pointer points to the first node of the linked list?
b. Determine the order of the nodes of the linked list.
c. Write a C++ code that creates and inserts a node with info 45 after the node with info 16.
d. Write a C++ code that creates and inserts a node with info 58 before the node with info 25.
Does this require you to the change the value of the pointer that was pointing to the first node
of the linked list?
e. Write a C++ code that deletes the node with info 25. Does this require you to the change the
value of the pointer that was pointing to the first node of the linked list?
6. What is the output of the following C++ code? (The class unorderedLinkedList is as defined in
this chapter.) Assume input is:
45 35 12 83 40 23 11 98 64 120 16 -999
unorderedLinkedList list;
unorderedLinkedList copyList;
int num;
cin>>num;
while (num != -999)
{ if (num % 4 == 0 | | num% 3 == 0)
list.insertFirst (num);
else
list.insertLast (num);
cin>>nume;
}
cout<<"copyList = ";
list.print();
cout<
copyList = list;
copyList.deleteNode(33);
copyList.deleteNode(58);
cout<<"copyList = ";
copyList.print()