Question: Exercise 7. In all this exercise, we consider the following structure type cell whose purpose is to represent linked lists of character strings: struct cell

 Exercise 7. In all this exercise, we consider the following structuretype cell whose purpose is to represent linked lists of character strings:

Exercise 7. In all this exercise, we consider the following structure type cell whose purpose is to represent linked lists of character strings: struct cell char *key; struct cell *next; $7a. A bug is hidden in the code below of the function cons on a linked list of strings whose intended purpose is to append a string of characters string to a list list. Can you detect the bug, explain what bad effect could happen at run time, and sug- gest how to correct it? struct cell cons (char string, struct cell list.) struct cell *newlist; new list (struct cel malloc (sizeof (struct cell new list >key strdup (string) new list next ist return newlist; $7b. A bug is hidden in the code below for the function free list whose intended purpose is to deallocate a linked list of strings. Can you find the bug and explain how to correct it? void free ist (struct cell ist) struct cell ptr while (list NULL) ptr list list list next free (ptr); return $7c. Worse, two bugs are hidden in the code below of the function clone list whose intended purpose is to clone a linked list of character strings, that is, produce two equal but absolutely independent lists list and clone list (list) in the end. Can you find the bugs and explain how to correct them

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!