I dont understand how to make the odd function
okay, follow this approach
take four pointers and initialise all to NULL
oddend and evenend to store the ends of even number and odd numbers
and oddstart and evenstart to store the beginning of them
check the first node if it is odd or even and point oddstart or evenstart accordingly
now for temp = head->next start running a loop
in the loop:
if an odd number is encountered and if oddstart is NULL point oddstart to it else if oddstart->next==NULL point odd end else point oddend->next to this temp and move oddend to it next
similarly follow the simlar steps for even numbers
at the end of the loop point oddend to even start and return oddstart as your new head
i dont able to understand what u have said…plz give in code form.
or explain it nicely…
node *oddeven(node *head)
{
if(head==NULL || head->next ==NULL)
return head;
node *oddend = NULL;
node *evenend = NULL;
node *oddstart = NULL;
node *evenstart = NULL;
if( head is odd)
oddstart = head;
else
evenstart = head;
head = head->next;
while(head!=NULL)
{
if(head is odd)
{ if(oddstart = NULL;
oddstart = head
else
oddend = head
}
else
{
if evenstart == null
evenstart = head;
else
evenend = head;
}
head = head->next;
}
oddend->next = evenstart
return oddstart
}
btao yr…its been 24 hrs
hey the code i gave was psuedo for understanding only