Considering a list like 1->2->3->4->5
Tlist is made like this:
typedef struct node{
int info;
struct node *link;
}Tnode;
typedef Tnode *Tlist;
I got the function listDeleteOdd which is built like this
Tlist listDeleteOdd(Tlist list) {
if (list == NULL)
return NULL;
if (list->info % 2 == 1) {
Tnode *node = list->link;
DeleteNode(list);
return listDeleteOdd(node);
}
Tnode *node = listDeleteOdd(list->link);
list->link = node;
return list;
};
Delete node just frees the memory of the given node ofc. By the way I dont understand how the value Tnode *node after the second if changes . Like it should be NULL couse the cycle return NULL when the prototype "list" reaches the end. After the cycle reaches the end what happens to node and the end the 'return list;' what it returns ??
I studied recursion some months ago and now it's all so confusing . There is there someone who can explain me how the whole function works properly couse i kinda understand how it works but i think there are some steps which are not really clear in my mind. Thx for the patiente in advance .