Q. Write down an algorithm to insert a node in between any two nodes in a linked list
Ans.
Insertion of a the node after the given element of the listis as follows
Node * InsertAfterElement (node * start, int item, int after)
{
node * ptr, * loc;
ptr =(node *) malloc (sizeof (node));
ptr->info = item;
loc=start;
while (loc != NULL && loc->info != after)
loc= loc->next;
if (start==NULL) { ptr->next= NULL;
start = ptr;}
else if (loc l = NULL){ ptr->next = loc->next; loc->next= ptr;}
return start;
}