Deletion at different positions in a Circular Linked List | Function to delete First node of Circular Linked List ; Check if list doesn 't have any node  if not then return ; Check if list have single node if yes then delete it and return ; Traverse second node to first ; Now previous is last node and first node ( firstNode ) link address put in last node ( previous ) link ; Make second node as head node
static void DeleteFirst ( Node head ) { Node previous = head , firstNode = head ; if ( head == null ) { System . out . printf ( " List is empty "); return ; } if ( previous . next == previous ) { head = null ; return ; } while ( previous . next != head ) { previous = previous . next ; } previous . next = firstNode . next ; head = previous . next ; System . gc ( ) ; return ; }