Question: 2 ) The following programs can be used for self-studying for linked list insertion sort operation: #include #include #include #define NULL 0 struct node {

2) The following programs can be used for self-studying for linked list insertion sortoperation:

#include

#include

#include

#define NULL 0

struct node

{

char info[10];

struct node *n;// link field

};

int main(void)

{

typedef struct node *NODEPTR;

char a[10];

int cnt=0;

NODEPTR x , y , save , head , p , q;

x = (NODEPTR)malloc(sizeof(struct node));

y = (NODEPTR)malloc(sizeof(struct node));

head = x;

x->n = y;

y->n = NULL;

strcpy(x->info,"cemal");

strcpy(y->info,"mert");

do

{

puts("Enter Name information(Using lover case character)");

gets(a);

cnt++;

q = NULL;

for(p = head; p != NULL && strcmp(a, p->info)>0; p = p->n)

q = p;

if (q == NULL) {

p=(NODEPTR)malloc(sizeof(struct node));

strcpy(p->info,a);

p->n = head;

head = p;

}

else

{

save=p;

p = (NODEPTR)malloc(sizeof(struct node));

strcpy(p->info,a);

p->n = save;

q->n = p;

}

}while (cnt!=3);

for(save = head;save != NULL;save = save->n)

printf("Traverse Node =%s ",save->info);

getchar();

}

3)Complete above program in a way that will delete any given person(name will be taken from the keyboard) from the linked list structure. List content of linked list after deletion.

Note: Give error message if the given person is not in the linked list.

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!