Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions