Even-after-odd code problem

codelink:https://pastebin.com/sup6PXJm
what’s wrong in my code please correct it

Hey,
there are a lot of corrections that need to be made in the evenodd function:

  1. You are updating the main iterator node (current) which should never be done
  2. There is a lot of pointer manipulation happening which is incorrect at many points.

MAIN thought process to proceed through the question :

  1. iterate over the linked list once,
  2. 2 cases: present element odd?
    if odd_head == NULL ? odd_head = curr : { move the odd iterator and add the current node to the odd linked list}

present element is even ?
if even_head == NULL ? even_head = curr : { iterate the even_pointer and add curr node to even linked list}

NOTE : after even_head odd_head != NULL keep them at the first node itself dont move them , move the iterator node.

Corner case :
1. odd_head == NULL ie all nodes are even valued. return even_head
2. if even head == NULL , put even_iterator->next = NULL
Try coding it yourself , then refer to the updated code

Happy to help.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.