Else insert the temporary node after the tail of the existing node and make the temporary node as the tail of the linked list
else { while ( tail != null ) { if ( tail . next == null ) { tail . next = temp ; tail = tail . next ; } tail = tail . next ; } }