I have an assignment to write a pseudo-code to have a list pointed by H (list of numbers) that have to be copied to a list pointed by H1 (only the odd numbers need to be copied). Can anyone tell me if I am wrong on this (not a working code just the core part that copies the odd numbers, sorry if code does not make sense I am completely new to linked list):
Algorithm Node *evenOut(struct node *H, struct node *H1)
Input: A list of numbers
Output: A list pointed by H1 that only contains odd numbers
node *current = H;
node *oddCurrent = H1;
node *startPointerForOdd = NULL;
node *temp1 = current;
node *temp2 = oddCurrent;
node *next;
int valueOfNode;
if (current == NULL)
{
Return 0;
}
else
{
while(current != NULL)
{
valueOfNode = temp1->next->value;
if(valueOfNode % 2 != 0)
{
if(startPointerForOdd == NULL)
{
temp2 = valueOfNode;
startPointerForOdd = temp2;
}
else
{
temp 2 = startPointerForOdd;
while(temp2 ->next != NULL)
{
temp2 = temp2->next;
}
temp2->next->value = valueOfNode;
}
}
}
}