Question: (C++ DATA STRUCTURE) QUESTION: Show the data structure for a method that allows the user to place a new node at a specific location in

(C++ DATA STRUCTURE)

QUESTION: Show the data structure for a method that allows the user to place a new node at a specific location in a list.

************************************************* USE DATA STRUCTURE TO MAKE A GRAPHICAL REPRESENTATION OF YOUR SOLUTION AND ANSWER THE QUESTION, IS NOT ONLY ABOUT THE CODE, BUT ALSO ABOUT ILLUSTRATION. *************************************************

CODE BELOW:

LISTREC * InsertAt(LISTREC *liststart, ENTRY newentry, int n)

{

int i = 0;

//LISTREC * liststart;

LISTREC * last = NULL;

LISTREC * next = liststart;

if (liststart == NULL)

{

liststart = (LISTREC*)malloc(sizeof(LISTREC)); /*creates new node*/

liststart->info=newentry;

liststart->link = NULL;

printf(" Created node at %d",i);

}//if

else while ((next->link != NULL) && (i != n))

{

last = next;

next = next->link;

++i;

}//else while

if (next == NULL)

{

next = (LISTREC*)malloc(sizeof(LISTREC)); /*creates new node*/

next->info=newentry;

next->link = NULL;

printf(" Created node at %d",i);

}//if

else if (i==n)

{

last->link = (LISTREC*)malloc(sizeof(LISTREC)); /*creates new node*/

last->link->info=newentry;

last->link->link = next;

printf(" Created node at %d",i);

}//else

return liststart;

}// insertAT

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!