Delete First Node from Singly Linked List
Program :
void del_beg() { struct node *temp; temp = start; start = start->next; free(temp); printf("nThe Element deleted Successfully "); }
Attention :
Step 1 : Store Current Start in Another Temporary Pointer
Step 1 : Store Current Start in Another Temporary Pointer
temp = start;
Step 2 : Move Start Pointer One position Ahead
start = start->next;
Step 3 : Delete temp i.e Previous Starting Node as we have Updated Version of Start Pointer
free(temp);
No comments:
Post a Comment