Assume the following doubly-linked list with the two pointers p1 and p2: Find th
ID: 3626309 • Letter: A
Question
Assume the following doubly-linked list with the two pointers p1 and p2: Find the values of each expression.Explanation / Answer
1. p1->data = I Reason: It is pointing to the bolck having value I. 2. p1->next->data = R. Next to I is R. 3. p1->prev->prev = NULL; It's the first node having previous value null. 4. p1->next->next = p2; This node is next to next of I. which is p2. 5. p1->prev->next = p1; previous to next is same p1. 6. p2->prev->prev->data = I. prev to prev of p2 is p1. p1 having data I. 7. p2->prev->prev->prev->prev = NULL; p2->prev->prev->prev is first node , prev of first node is null so it is NULL. 8. p2->prev->prev>next->data = R. p2->prev->prev is p1. p1->next->data is R node. 9. Contents will be D,I,R,T,Y which can be accessed as p1->prev->data, p1->data, p1->next->data, p1->next->next->data, p1->next->next->next->data 10. p1->prev->data = 'M'; p1->next->data = 'S'; 11. p1->next->next = p1->next->next->next; p1->next->next->prev = p1->next; free(p2);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.