Question: 8. (5 points) Assume the following definition for a node of a singly linked list. public class Node { public int data; public Node next;

8. (5 points) Assume the following definition for a node of a singly linked list. public class Node { public int data; public Node next; public Nadelant d) { data = d; next = null; } (a) (3 points) Write an iterative function guan.) which calculates and returns the sum of all the integer data values stored in the linked list. The head of the list is given as a parameter. public static int sun Node head) { (b) (2 points) Write a recursive function SunRO which calculates and returns the sum of all the integer data values stored in the linked list. The head of the list is given as a parameter. public static int sumo (Node head)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
