Please write simple program: Write each code separately! 1.) Add a node at the b
ID: 3659090 • Letter: P
Question
Please write simple program: Write each code separately! 1.) Add a node at the beginning of a Linear Linked List 2.) Add a node at the end of a Linear Linked List 3.) Add a node after the first node in a Linear Linked List 4.) Add a node before the first node in a Linear Linked ListExplanation / Answer
struct node{ int data; node *next; } int main(){ //Add a node at the beginning node temp = new node; cin>>temp.data; head = temp->next; //Add a node at the end node temp1 = new node; cin>>temp1.data; tail->next = temp1; temp1->next = NULL; tail = temp1; //Add a node After First Node node temp2 = new node; cin>>temp2.data; temp2->next = head->next; head->next= temp2; //Add a node before the first Node node temp3 = new node; cin>>temp3.data; head = temp3->next; return 0; }
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.