Hi!
Could someone please help me to understand the use of merge algorithm(conce ptually) with linked lists. What I want to do in the linked list function is:
the function gets two inputs, i.e the pointers to the two smaller lists, then the function should able to merge these two together, and then return the head-pointer to this merged list. What happens in my case, is that I "lose" data when running it . My result is like...
User Profile
Collapse
-
Sorry, I forgot to show the struct itself:
[CODE=c]typedef struct set_node set_node_t;
struct set_node {
set_node_t *next;
void *elem;
};
struct set {
int size;
set_node_t *head;
cmpfunc_t cmpfunc;
};[/CODE] -
need help with a union function in a linked list
Hi!
Programming language: C
I wondered if any of you are able to see what is wrong with my code. What I want to do is to find the union of a set of numbers. I use a singly linked list. and my union function is based on a simple merge algorithm.
There are four different sets: even numbers, odd numbers, prime numbers and non prime numbers.
When I run my program now, it prints out:
Even or Odd numbers: 0 1...
No activity results to display
Show More
Leave a comment: