Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My code is below, I don't know if my code is right or wrong, can someone help me to check? You don't need to run

My code is below, I don't know if my code is right or wrong, can someone help me to check? You don't need to run the code, pls fixed my code if you can.

############

to insert the value of 5 right before the value in the node pointed to by Node *current (non null). write several statements that accomplish this.

Here is the declaration for Node:

struct Node {

int data;

Node * previous, *next;

};

inserted using new and assign 5 to it's data member as well as give appropriate values to its previous and next pointers to link correctly. Be mindful of the case where current is at the beginning of the list, so current->previous will be null.

############

struct Node { int data; Node *previous, *next; };

int main(){ Node *current; insertAfter(5) break; }

void insertAfter(5) { struct Node *newNode; newNode = (struct Node*)malloc(sizeof(struct Node)); newNode->data = value; if(current->previous = NULL) { newNode->previous = NULL; newNode->next = current; current->previous = newNode; } }

image text in transcribed

struct Node ( int data; Node *previous, *next; 10 int main) f Node *current; insertAfter (5) break 12 13 14 15 16 void insertAfter (5) 18 19 20 21 struct Node newNode newNodestruct Node*) malloc (sizeof (struct Node) newNode->data value ; if (current->previousNULL) 23 24 25 26 27 28 newNode-previousNULL newNode-nextcurrent; current->previous - newNode

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

How does an organization know if it is pursuing optimal strategies?

Answered: 1 week ago