Spread the post

Sum of even and odd nodes in a linked list

Sum of Even and Odd nodes of a given linked list, suppose linked list contain following nodes [1,2,3,4,6,5,7,8].

Even nodes are : 2, 4, 6, 8

Odd nodes are : 1, 3, 5, 7

root_ptr87564321|| Blue Odd node value Green are Even nodes value

View insertion and deletion of first node process

Try it yourself

Function to perform sum operation.

Time complexity of this program O(n).

C Program to sum even and odd nodes.


OutPut


Stack Areamainroot(pointer) Heap Areastruct Nodedata (int)= 1next (pointer) struct Nodedata (int)= 2next (pointer) struct Nodedata (int)= 3next (pointer) struct Nodedata (int)= 4next (pointer) struct Nodedata (int)= 6next (pointer) struct Nodedata (int)= 5next (pointer) struct Nodedata (int)= 7next (pointer) struct Nodedata (int)= 8next (pointer)= NULL

Try it yourself

Spread the post

Recommended Posts: