Question: Linked list is a type of data structure. Each item of the list holds a data and a pointer to the next item. Head is

Linked list is a type of data structure. Each item of the list holds a data and a pointer to the next item. Head is a pointer that points to the first element. Tail is the last element of the list, which points to NULL. Linked list can be implemented using structures, consisting of some data types and a pointer.

Write a program that will create the linked list in the figure below and prints out the data in order. Make sure to include functions for insert, delete, and search. Use the following list.h file to create the linked list.

"list.h" file:

#include

typedef char DATA;

struct linked_list {

DATA d;

struct linked_list *next;

};

typedef struct linked_list ELEMENT;

typedef ELEMENT *LINK;

Linked list is a type of data structure. Each item of the

I've already done some of the program so far. I'll show that below but I'm struggling to finish it.

/* function to insert a node into the list */

void insert(LINK p1, LINK p2, LINK q) {

assert(p1 -> next == p2);

p1 -> next = q;

q -> next = p2;

}

/* function to delete a node from the list */

void delete(LINK p1) {

p1 -> next = p1 -> next -> next;

}

/* function to print the list */

void print_list(LINK head) {

if (head == NULL)

printf("NULL ");

/* While list not null, print each node */

else {

printf("%c --> ", head -> d);

print_list(head -> next);

}

}

data next data next data next data next 10 2 head

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!