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

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

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!