hey guys, in preperation for my midterm I'm doing a whole bunch of different exercises with linked lists and recursion. The following is one which I'm having a bit of trouble with, but I think I'm on the right track;
The question asks for a recursive function which takes a pointer to a singly linked list, where the elements are in order, (ie. 1 3 4 5). without creating a new list make the lists elements add up in the following way:
I hope all you know what the question is asking for. Anyhow, here is the code I wrote. Can anyone tell me if it is right or wrong. By my logic it looks pretty good.
//original list: 2, 3, 4, 7
//output list: 16 ,14 ,11 ,7
void suffix(cNode * L)
if(L == NULL || L->next == NULL)
L->elem = L->elem + L->next->element;