Question: Use data structure to show how to add a created node to the front of the list. The answer is more about a graphical representation

Use data structure to show how to add a created node to the front of the list. The answer is more about a graphical representation of how to add a node to the front of a list again, and not about coding (in other words, about visuals).

code:

void listinsert(ENTRY newentry,LISTREC *liststart) { LISTREC *last,*next; next = liststart;

while ((strcmp(newentry.name,next->info.name)> 0) && (next->link != NULL)) { last = next; next = next->link; } /*end while*/

if (strcmp(newentry.name,next->info.name) == 0) /*if both are same*/ next->info = newentry; /*updates*/ else if (strcmp(newentry.name,next->info.name) < 0) { last->link = (LISTREC*)malloc(sizeof(LISTREC)); /*creates new node*/ last->link->info=newentry; last->link->link = next; } else { next->link = (LISTREC*)malloc(sizeof(LISTREC)); next->link->info = newentry; next->link->link = NULL; } /* end else */ printf(" After insertion, linked list: "); prntlist(liststart); } /* end function listinsert*/

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!