Reversing the ordered Singly Linked List for Data Structure in'C'

Special Operation on linked lists:

Reversing the ordered Singly Linked List:
              In order to reverse the ordered singly linked list, the root must point to the last node of the list. The first node’s address must be copied to the link of second node. Similarly the address of each node is copied in the link of the next node. It works like exchanging the links of each node with the address of the previous node. The algorithm is simple and self-explanatory.
The same is given as follows:

FIRST<--ROOT [To store the first node’s address]
PPTR<--ROOT        [To store the address in link]
NPTR<--ROOT-->LINK [To store address of previous node]
Repeat While NPTR< >NULL
[End of while]
FIRST-->LINK<--NULL [To make first node as last]
Return ROOT


Popular posts from this blog

difference between structure and union in C Language

Difference between Linear search and Binary Search in c language

Difference between static and dynamic websites