Question: / / list: ptr to a linked list of Node ( each with int data, and Node * next ) / / Return the sum

// list: ptr to a linked list of Node (each with int data, and Node * next)// Return the sum of all values in the list. // You may assume that list is not NULL // However, the list may be empty (i.e. list->head may be NULL)11 in which case your code should return O. int sum(LinkedList * list){// Code may assume that these assertions are true; // so does not need to do error checking for these conditions. assert(list !=NULL); // TODO: Insert code here to calculate and return // sum of all values in list (o if there are none). return -42; // STUB! Replace this line with correct code ---------SUM---- FAILED: sum(listi) Expected: 73 Actual: -42 FAILED: sum(list2) Expected: -28 Actual: -42 FAILED: sum(list3) Expected: 6 Actual: -42 FAILED: sum(list4) Expected: 3 Actual: -42

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!