Question: (b) The very, very buggy code below is intended to merge, in place, two sorted, linked lists into a single sorted, linked list: it is

 (b) The very, very buggy code below is intended to merge,

(b) The very, very buggy code below is intended to merge, in place, two sorted, linked lists into a single sorted, linked list: it is supposed to take two lists as input and destructively modify them so that at the end, they form a single, sorted, linked list in memory. Find as many potential bugs in the code as you can: typedef struct link { char *data; struct link *next; } list; list *merge (list *input1, list #input 2) { list *output - NULL, *tail, *next; do { if(strcmp(input1->data, input 2->data) next; } else { next - input2; input2 - input 2->next; if (output = NULL) { output - tail - next; } else { tail->next = next; tail - tail->next; } while (input1 != NULL && input2 != NULL); if (input1 != NULL) tail->next = input1; else tail->next - input2; return output; (b) The very, very buggy code below is intended to merge, in place, two sorted, linked lists into a single sorted, linked list: it is supposed to take two lists as input and destructively modify them so that at the end, they form a single, sorted, linked list in memory. Find as many potential bugs in the code as you can: typedef struct link { char *data; struct link *next; } list; list *merge (list *input1, list #input 2) { list *output - NULL, *tail, *next; do { if(strcmp(input1->data, input 2->data) next; } else { next - input2; input2 - input 2->next; if (output = NULL) { output - tail - next; } else { tail->next = next; tail - tail->next; } while (input1 != NULL && input2 != NULL); if (input1 != NULL) tail->next = input1; else tail->next - input2; return output

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!