Question: above in the image is a linked list with 2 nodes. You can use this or write a similar one. The assignment is to write
above in the image is a linked list with 2 nodes. You can use this or write a similar one. The assignment is to write 2 functions. One function will add another node at the end of the list. The other function will delete a node. Don't forget - No dangling pointers
C++ language
Make sure its corect and runs without errors and I promise to give you a thumbs up.
#include iostream using namespace std; class Node int data; Node *next; public void setdata(int d) data d;) void setnext (Node p)next P; int getdata() Treturn data;) Node getnext() freturn *next;) d: int main() Node *N1 = new Node; N1->setdata (1000); Node "N2 = new Node; N2->setdata (2000); N1->setnext( N2) ; N2->setnext (NULL); system("pause"; return 6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
