Consider the C code fragment given below.
typedef struct node {
int data;
node* next;
} node;
void join(node* m, node* n) {
node* p = n;
while(p->next != NULL) {
p = p->next;
}
p->next = m;
}
Assuming that m and n point to valid NULL-terminated linked lists, invocation of join will
- append list m to the end of list n for all inputs.
- either cause a null pointer dereference or append list m to the end of list n.
- cause a null pointer dereference for all inputs.
- append list n to the end of list m for all inputs.