1. Answer the following questions for the linked list and node refereces P1, P2, P3 and P4 (Here Cat, Dog, Ewe, and Rat are the data content of nodes, and P1, P2, P3, P4 are four references, the same as first reference).

Draw a similar diagram as below to show how this configuration changes when the given program segment is executed, or explain why an error occurs (data is a string in every node).

Every subquestion is independent and based on the initial figure shown below. see image.

a. P1 = P2.next;

b. P4 = P1;

c. P4.data = P1.data;

d. P4.next.data = P1.data;

e. P2.next = P3.next;

f. P4.next = P1;

g. P1.next = P3.next;
P1 = P3;

h. P1 = P3;
P1.next = P3.next;

i. P4.next = P3.next;
P3.next = P2.next;
P2.next = P1.next;

j. P4.next = P3;
P4.next.next = P2;
P4.next.next.next = P1;
P1.next=null;

2. Answer the following questions for following doubly-linked list with the two references P1 and P2: (Find the value of each expression.) see image.

Every subquestion is independent and based on the initial figure shown above.

a. P1.data;
b. P1.next.data;
c. P1.prev.prev;
d. P1.next.next;
e. P1.prev.next;
f. P2.prev.prev.data;
g. P2.prev.prev.prev.prev;
h. P2.prev.prev.next.data;

3. Answer all the sub-questions for Problem 2 but for the following circular doubly-linked list with the two references P1 and P2: (Find the value of each expression.) see image.

Every subquestion is based on the initial figure shown above.

a. P1.data;
b. P1.next.data;
c. P1.prev.prev;
d. P1.next.next;
e. P1.prev.next;
f. P2.prev.prev.data;
g. P2.prev.prev.prev.prev;
h. P2.prev.prev.next.data;

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.