Delete node at any position in singly linked list

Step1: first check the head status, if head status is NULL then it is EMPTY LIST, so no need to perform any task.

Step2: if head status is other then NULL then,

Get node count value.

Get node position value to perform delete operation.

Validate node position value, if valid position, then go for further process.

Step3: if node count value is 1. Then process following steps

De-allocate memory for head.

Assign NULL value to head

Step4: if node position is 1, then processing following steps

Create a temporary head i.e. th1 and assign current head value to th1.

Shift the current head to next node i.e. head = head->next;

Remove next node relation with temporary head i.e. th1->next=NULL.

De-allocate memory of temporary head. i.e.th1.

Step5: if node position value is other then 1, then process following steps

Take a temporary head i.e. th1 and assign current head value to th1.

Create a loop and travel up to link position-1.

Step6: Create another temporary head i.e. th2 and assign previous node next address to th2. i.e. th2=th1->next.

Assign previous node next value to current nodeĀ  next value i.e. th1->next=th2->next.

Remove next node relation with temporary head i.e. th2->next=NULL.

De-allocate memory for temporary head. i.e th2.

Scroll Up