InterviewSolution
Saved Bookmarks
| 1. |
A linked list is formed from the objects of the class Node. The class structure of the Node is given below:class Node { int num; Node next; }Write an Algorithm OR a Method to find and display the sum of even integers from an existing linked list.The method declaration is as follows: void SumEvenNode(Node str) |
|
Answer» void sumEvenNode(Node str) { if(str = null) return 0; else if(str.num % 2 == 0) return str.num + sumEvenNode(str.next); else return 0 + sumEvenNode(str.next); |
|