3) (10pts) DSN (Linked Lists) Write a recursive function that takes the head of
ID: 3744201 • Letter: 3
Question
3) (10pts) DSN (Linked Lists) Write a recursive function that takes the head of a linked list (possibly NULL) that contains positive integers only. The function must return-1 if the list contains any integer that is equal to the sum of all integers that come after it in the list. If not, the function can return whatever value you feel is appropriate other than -1. (Figuring out what to return is part of the fun for this problem.) For example, the function should return-1 for the following linked list because 4 is the sum of all the nodes that follow it (1, 2, and 1): 20-3 -1->4-1-> 2->1-NULL head The function signature and node struct are: typedef struct node ( int data; struct node *next; node int listylist (node *head) int sum if (head= NULL) return 0 sumlistylist(head->next); if (sum head->datasum) return -1; return head->data sumExplanation / Answer
As listed in the question above, there are few things to look up to.Here we go,
Hence, this is the only reason that can be connected over the use of the condition stated above.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.