Algorithm for Deleting the First Node in Singly Linked List


Step 1: [Check for under flow ] 
      If START = NULL, then 
       print ('Linked list empty')
       Exit 
      [END OF IF] 
Step 2: Set PTR = START
Step 3: Set START = START -> next 
Step 4: Print, element deleted is, pra -> Info.
Step 5: free (ptr)

The C Code for the above algorithm is :

void delete (void)
{
 Node *P ;
 if (start == NULL)
 {
  return ;
 }
 else
 {
   P = start ;
   start = start -> next ;
   print ("Element deleted is = %d", P-> num) ;
   free (P) ;
 }
}