Monday, 17 February 2014

Insert a node in linked list in sorted manner.

Logic:
sort_addnode(data) function will add the data to linked list
in sorted manner.
for first node ,  It will assign head pointer to it.
After that we are comparing node info with new node's info.
we have maintained Predecessor pointer for our new node.
Look below figure


Sorted manner Insertion











After that it will be easy to add new node.

No comments:

Post a Comment