Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please follow instructions for question 22 and answer this asap and I promise to

ID: 3726590 • Letter: P

Question


please follow instructions for question 22 and answer this asap and I promise to give you a thumbs up

22) The class below defines a node for a linked list. Write a FUNCTION called INSERT that inserts a node at the end. Assume that one node named HEAD has already been created. Your function should take any node names as arguments that the user enters in the function call and should assign data. 12 points PLEASE PUT ANSWER HERE class Node string name int data; Node *next public: Node( (next NULL;: woid setnamelstring n) Iname n:) void setdatalint d) (data d:) void setnextINode "plt next p: string getnamell (return name: int getdata(l freturn data;) Node getnext0 freturn "next: 23) FOR THE LINKED LIST BELOW, CHANGE TO MAKE secondptr the first node and head the second node. Also make it a doubily linked list Note: you just have to change links. 10 points double value ListNode "next; ListNode "prev int main ListNode *head; head new ListNode head-svalue 12.5 head->next = NULL; ListNode "secondPtr new ListNode; secondPtr->value 13.5; secondPtr->next NULL; head->next secondPtr;

Explanation / Answer

void insert(Node *HEAD, string name, int data) {

Node * newNode = new Node();

newNode.setname(name);

newNode.setdata(data);

Node *start = HEAD:

while(start.getnext() != null) {

start = start.getnext();

}

start.setnext(newNode);

}

=================

head->prev = secondPtr;

secondPtr->prev = NULL;

secondPtr->next = head;

head = secondPtr;

secondPtr = head->next;