Delete all odd or even positioned nodes from Circular Linked List | Function to delete that all node whose index position is odd ; Check list have any node if not then return ; If list have single node means odd position then delete it ; Traverse first to last if list have more than one node ; Delete first position node which is odd position ; Function to delete first node ; Check position is odd or not if yes then delete node Note : Considered 1 based indexing
function DeleteAllOddNode ( head ) { let len = Length ( head ) ; let count = 0 ; var previous = head , next = head ; if ( head == null ) { document . write ( " " + " " + " " ) ; return null ; } if ( len == 1 ) { head = DeleteFirst ( head ) ; return head ; } while ( len > 0 ) { if ( count == 0 ) { head = DeleteFirst ( head ) ; } if ( count % 2 == 0 && count != 0 ) { head = deleteNode ( head , previous ) ; } previous = previous . next ; next = previous . next ; len -- ; count ++ ; } return head ; }