Hi I need to do a recursive function that takes in input the head of a list and sum to each node all the nodes that come after that node. Example if the list is 1->2->3 the list will be modified in 6->5->3. I have done an iterative function that works good but I have no idea of how do a recursive one, can you help? This is the iterative one:
int modify(node *head){
node **curr;
node *track = head;
int i;
while (track->next != NULL){
*curr = (track)->next;
while((*curr)->next != NULL){
track->val += (*curr)->val;
*curr = (*curr)->next;
}
track = track->next;
}
track = head;
while (track->next != NULL){
printf("%d ",track->val);
track = track->next;
}
printf("\n");
return head->val;
}