Question: Can someone help me with this assignment? All the codes should be written in C++. Write a program that performs opcrations on a singly linked
Can someone help me with this assignment? All the codes should be written in C++. Write a program that performs opcrations on a singly linked list. Given the following structure definition: struct ListNode int data; struct ListNode next; Write code that implements the following function prototypes: /l Creates a new node with the argument data and adds it to the end of the argument list. The return value is the list with the new node. ListNodeaddToListEnd(ListNodelist, int d); l Creates a new node with the argument data and inserts it directly after I/ the argument node. void addAfterNode(ListNode *node, int d) I Creates a list of new nodes with all data copied from the argument list, then returns the new list. ListNode "copy List( ListNodelist); W Deletes the argument node from the argument list, then returns the new W list. ListNode "deleteNode(ListNode "list, ListNode "ioDelete); l Deletes all nodes in the argument list. void destroyList(ListNode list); W Prints all the node values in the list, separated by spaces void printList(ListNode list) List nodes should be added with the new operator and deleted with the delete operator. Then, add a driver program in your main function which demonstrates each of these functions. For example, if your driver program had these statements: ListNode "myList; ListNode "myListCopy, myList- addToListEnd(NULL, 1; creates list with 1 myList- addToListEnd(myList, 3) /W appends 3 to list myList-addToListEnd(myList, 4);0 appends 4 to list printList(myList); addAfterNode(myList, 2); lI adds 2 after I printList(myList) myListCopy- copyListl myList) printList(myListCopy); destroy Listi(myListCopy) myList deleteNode( myList, myListnext>next); I deletes 3 from list printList(myList); destroyListmy Lis); Then the program output should be: 134 1234 1234 124 Save this program in a file named linkedlist.cpp and submit it
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
