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;