Question: Write an algorithm (in C++) for inserting a node in between k-1 node and k-th node on a singly linked list. After the insertion, your

Write an algorithm (in C++) for inserting a node in between k-1 node and k-th node on a singly linked list. After the insertion, your function returns the pointer which points to the head of the list. If the present linked list has less than k nodes, the node should be inserted as the last node on the list when it is done. The node is defined as struct node {int INFO; node *NEXT ; Your algorithm needs to meet all conditions as follows: (a) if the list is empty; (b) if the node is the first node on the list (k=1 ); (c) if the node is the last node on the list; (d) if the number of nodes on the list are less than k; (e) Assume the head pointer of the list is HEAD
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
