Sum Numbers in a Linked List
This lesson will teach you how to calculate the sum of numbers in a linked list using recursion.
We'll cover the following...
We'll cover the following...
Sum n numbers
When given a linked list, sum the values of all the nodes and then return the sum.
The following illustration explains this concept:
Implementing the code
The following code calculates the sum of the node values in the linked list using recursion.
Experiment with the code by changing the elements of the list to see how it works.
Understanding the code
The code given above can be broken down into two parts: ...