0% found this document useful (0 votes)
8 views1 page

Important Linked List Functions

Uploaded by

f20220732
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Important Linked List Functions

Uploaded by

f20220732
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Important Linked List Functions

1) Node *segregateEvenOdd(Node *head)


{
Node *ee;
Node *es;
Node *os;
Node *oe;
int ce=0;
int co=0;
Node *curr = head;
while(curr!=NULL)
{
if(curr->data%2==0)
{
if(ce==0)
{
es = curr;
ee = es;
}
else
{
ee->next = new Node(curr->data);
ee = ee->next;
}
ce++;
}
else
{
if(co==0)
{
os = curr;
oe = os;
}
else
{
oe->next = new Node(curr->data);
oe = oe->next;
}
co++;
}
curr = curr->next;
}
ee->next = os;
return es;
}

You might also like