Learn basic concept of c , c++ and python programming in regularcodes.com

Spread the post

Segregate even and odd nodes in a Linked List

Given an unsorted linked list. modifying this linked list to satisfied following property.

1) Arrange all even node at start.

2) After even node arrange odd nodes.

Given of a example of this problem.

Suppose following data are inserted on linked list.


Try it Yourself

View odd and even nodes





C program to Segregate even and odd nodes in a Linked List .


Code execution: view code execution process.

Stack Areamainroot(pointer)segregate_nodeeven_ptr(pointer)hold(pointer)odd_ptr(pointer)root(pointer)temp(pointer) Heap Areastruct Nodedata (int)= 1next (pointer) struct Nodedata (int)= 1next (pointer) struct Nodedata (int)= 8next (pointer) struct Nodedata (int)= 9next (pointer) struct Nodedata (int)= 5next (pointer) struct Nodedata (int)= 4next (pointer) struct Nodedata (int)= 3next (pointer) struct Nodedata (int)= 2next (pointer)= NULL

Try it yourself

Spread the post

Recommended Posts: