Removing First Node from the List :



If the list has multiple elements:

RemoveAfter():
- Read node location
- Check the location is present or not
- If location is out of list, return with Error message
- If the location is present with next node availability, delete the next node of specified location.


void removeAfter() { int loc, len, i=1; struct Node *p, *q; printf(“Enter location to remove after : “); scanf(“%d”, &loc); len = length(); if(loc >= len){ printf(“Invalid location”); return; } p = start; while(i<loc){ p=p->right; i++; } q = p->right; p->right = q->right; if(q->right){ q->right->left = p; } q->left = NULL; q->right = NULL; free(q); } |