Question: Write the following functions in C based on the double list structure: typedef struct double_list { char *first_name; char *last_name; int age; struct double_list *prev_ptr;

Write the following functions in C based on the double list structure:

typedef struct double_list { char *first_name; char *last_name; int age; struct double_list *prev_ptr; struct double_list *next_ptr; } double_list;

1. void delete_double(double_list **);

The argument points to a double_list structure. Deallocate it and the strings that its fields point to. Set the pointer that points to the double_list structure to NULL. Do not deallocate the structure(s) pointed to by prev_ptr and next_ptr. The function should assert that the argument is not NULL and that the pointer pointed to by the argument is also not NULL. This function should assert that the next_ptr and prev_ptr fields of the element to be deleted are NULL.

2. void delete_double_list(double_list **);

The first argument points to a doubly-linked list. Deallocate each element of the list. It is not an error for the argument to be NULL. If it is NULL, there is nothing to do. Note that this function should call your delete_double() function to simplify the operation. Keep in mind that the pointer pointed to by the argument to this function may be the head of the list, the tail of the list, or anywhere in between.

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!