Task:“Compute the sum of all the values in the nodes of a single linked list”
The only thing is needed to solve this problem is linked list traversal. So we can easily modify function getLenght into following solution:
public int getSum(Node head)
if (head == null)
else return getSum(head.next) + head.value;
Think how would you modify this function to implement search for the value in linked list.