Skip to main content

logic of reversed list


NodePtr revList = NULL

NodePtr currNode = currHead;

while(currNode != NULL)
{
        // Set the head to the next node
        currHead=currHead->next;
   
        // Link currNode to the reversed list
        currNode->next=revList;
        revList=currNode;
   
        // Move currNode to next node
        currNode=currHead;
        currHead=revList;
}