Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I dont understand why you have to check if sum == -1. Can someone please explain. 3) (10pts) DSN (Linked Lists) Write a recursive function
I dont understand why you have to check if sum == -1. Can someone please explain.
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 sumStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started