Question: v Add Node to a List Problem Statement Write a function add(Node* head, int index, int value) to add a node to a linked list.

v
v Add Node to a List Problem Statement Write a function add(Node*
head, int index, int value) to add a node to a linked
list. The head of the linked list is input, as well as
the Index where the node should be added and the value associated

Add Node to a List Problem Statement Write a function add(Node* head, int index, int value) to add a node to a linked list. The head of the linked list is input, as well as the Index where the node should be added and the value associated with the node. The program returns the head of the updated list. If the index of insertion is greater than the size of the list, the program should return NULL We have defined the following node C++ class for your class Node public: int value; Node next = NULL; The program input is a value, an index, and a list Test cases . We have implemented the main() for you. The main calls your add() method Input Line 1 has three integers Integer 1 is the size of the list. This value is not passed into the function and is not accessible to you. Integer 2 is the value to be inserted. Integer 3 is the position at which the value needs to be inserted. Line 2 is the Linked List passed into the add() method with nodes separated by a space. Output: Traversal of the updated list. . Sample Input: 4 5 1 0 1 2 3 Sample Output: 0 5 1 2 3 Memory limit: 256 MB 1 #include 2 3. class Node { 4 public: 5 int value; 5 Nodex next = NULL; 71 8 9 Nodex add (Noder head, int index, int value input) 18+ 11 I 12} Submit Start over (reset) Runc

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!