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; publis Node (int d) { data = d; next = null; } } (a) (3 points) Write an iterative function sun 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. Bukute static int sum (Node head) { (b) (2 points) Write a recursive function sums 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 sums (Node head) {
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
