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

February 27, 2014 0 Comments

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

Jackrin Reacher

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google