Answer all the sub-questions for problem 2 but for the


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.

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; Cat Dog Ewe Rat P1 P2 P3 P4 null COSC 3331 DS & Algorithms hw3

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.)

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.)

Every subquestion is based on the initial figure shown above.

a. P1.data;

b. P1.next.data;

c. P1.prev.prev; D I R T Y null null null P1 P2 B E S T P1 P2 COSC 3331 DS & Algorithms hw3

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;

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: Answer all the sub-questions for problem 2 but for the
Reference No:- TGS01374319

Now Priced at $40 (50% Discount)

Recommended (97%)

Rated (4.9/5)