Delete all odd or even positioned nodes from Circular Linked List | Function to delete all even position nodes ; Take size of list ; Check list is empty if empty simply return ; If list have single node then return ; Make first node is previous ; Make second node is current ; Check node number is even if node is even then delete that node
static Node DeleteAllEvenNode ( Node head ) { int len = Length ( head ) ; int count = 1 ; Node previous = head , next = head ; if ( head == null ) { Console . Write ( " List is " return null ; } if ( len < 2 ) { return null ; } previous = head ; next = previous . next ; while ( len > 0 ) { if ( count % 2 == 0 ) { previous . next = next . next ; previous = next . next ; next = previous . next ; } len -- ; count ++ ; } return head ; }