Monday 29 August 2011

Deletion of the last node

Deletion of the last node

1. Declare necessary variable
2. If list = NULL
      print "Empty List"
    Else
      set p = list
      if p->next = NULL
         list = NULL
         delete(p)
     Else
      while(p->next!=NULL)
         temp = p
         p = p->next
      temp->next = NULL
      delete(p)
3. For next deletion goto step 2

No comments:

Post a Comment