Problem 1: Assume the following declarations:
struct Node {
char data;
Node* next;
};
Node* list;
And that the following linked list has been created:
For each of the following code segments start with this list and, draw a NEAT picture showing the resulting list(s), any unreferenced nodes, and where the pointers list and p point.
// a. Change List 1
for (Node* p = list; p != NULL; p = p->next) if (p->data == 'C') if (p->next != NULL) p->next = p->next->next;
for (Node* p = list; p != NULL; p = p->next) if (p->next != NULL) p->next = p->next->next;
for (Node* p = list; p != NULL; p = p->next) if (p->data == 'A' || p->data == 'E') p->data = '*';
Problem 2: Write a code segment that will change the data field of every node but the last one in list list to a 'Z'. (So list: FEDCBA becomes list ZZZZZA)
Last Updated: April 6, 1997 11:46 pm by