Sum of nodes in a linked list
Given a linked list which include integer elements. Our goal is to find sum of elements which is present in this linked list. We assume that the sum of nodes are not break the maximum and minimum integer.
List : 10 → -2 → 3 → NULL
Output : 11
List : 1 → 5 → 2 → 6 NULL
Output : 14
That is one of the basic problem to traverse linked list node, Which is easily solve using recursion and iterative manner.
Iterative solution
-
1) Sum of nodes in linked list in c
2) Sum of nodes in linked list in java
3) Sum of nodes in linked list in c++
4) Sum of nodes in linked list in golang
5) Sum of nodes in linked list in c#
6) Sum of nodes in linked list in vb.net
7) Sum of nodes in linked list in php
8) Sum of nodes in linked list in node js
9) Sum of nodes in linked list in typescript
10) Sum of nodes in linked list in python
11) Sum of nodes in linked list in ruby
12) Sum of nodes in linked list in scala
13) Sum of nodes in linked list in swift
14) Sum of nodes in linked list in kotlin
Using Recursion
-
1) Sum of nodes in linked list using recursion in c
2) Sum of nodes in linked list using recursion in java
3) Sum of nodes in linked list using recursion in c++
4) Sum of nodes in linked list using recursion in c#
5) Sum of nodes in linked list using recursion in vb.net
6) Sum of nodes in linked list using recursion in php
7) Sum of nodes in linked list using recursion in node js
8) Sum of nodes in linked list using recursion in typescript
9) Sum of nodes in linked list using recursion in golang
10) Sum of nodes in linked list using recursion in python
11) Sum of nodes in linked list using recursion in ruby
12) Sum of nodes in linked list using recursion in scala
13) Sum of nodes in linked list using recursion in swift
14) Sum of nodes in linked list using recursion in kotlin
Accepted time complexity is O(n).
Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.
New Comment